Email validation form in php
To verify email first we make our form and in this form make one input text field where user enters its email id and a submit button which when pressed shows that email is valid or not. In our php code we use regular expression to check the email whether its valid or not. In our php code we first check that whether form is submitted or not [...]
To verify email first we make our form and in this form make one input text field where user enters its email id and a submit button which when pressed shows that email is valid or not.
In our php code we use regular expression to check the email whether its valid or not. In our php code we first check that whether form is submitted or not by isset function. So the full code of email validation form is :-[code lang=”html”]
<?php
if(isset($_POST[‘submit’])){
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+
(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST[’email’])){
echo "<center>Invalid email</center>";
}
else{
echo "<center>Valid Email</center>";
}
}
?>
<html>
<head>
<title>Email Validation</title>
</head>
<body>
<form action="" method="post">
<p align="center">Enter Email: <input type="text" name="email" /><br />
<input type="submit" name="submit" value="Verify" /></p>
</form>[/code]
I have not apply any styling to keep the code short. But the main functionality is clear in the code. Thanks.
Share this article
Written by : Junaid Rehman
I am a blogger and freelance web developer by profession. I love to blog and learn new things about programming and IT World.
Follow us
A quick overview of the topics covered in this article.
Latest articles
February 13, 2025
February 13, 2025
February 13, 2025
February 13, 2025
February 13, 2025