Email validation form in php

1 min


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

	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>";
		echo "<center>Valid Email</center>";
<title>Email Validation</title>
<form action="" method="post">
<p align="center">Enter Email: <input type="text" name="email" /><br />
<input type="submit" name="submit" value="Verify" /></p>

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

Like it? Share with your friends!

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.