<?php
if(!empty($_POST['email'])){
$regularexp = "^[A-Za-z0-9\.|-|_]*[@]{1}[A-Za-z0-9\.|-|_]*[.]{1}[a-z]{2,5}$";
$email = $_POST['email'];
$validemail = ereg($regularexp, $email);
if ($validemail)
{
echo "<div style='color:green;'> <b>'$email'</b> is a valid email</div>";
}
else
echo "<div style='color:red;'> <b>'$email'</b> is not a valid email</div>";
}else{
echo "<div style='color:red; font-weight:bold;'> Please enter email</div>";
}
?>
<html>
<body>
<h2>Email Validator</h2>
<form method="post">
<div style="width:50px; font-family:Verdana, Arial, Helvetica, sans-serif; float:left; padding-top:3px;">
Email:
</div>
<div style="width:300px">
<input type="text" name="email" />
</div>
<input type="submit" />
</form>
</body>
</html>