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 :-

<?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>

I have not apply any styling to keep the code short. But the main functionality is clear in the code. Thanks.


Share This Story, Choose Your Platform!