Email validation with Regular Expressions : Email Validation « Email « PHP






Email validation with Regular Expressions

<html>
<head><title></title></head>
<body>
<?php

if (isset($_POST['posted'])) {

   $email = $_POST['email'];
   $theresults = ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $email, $trashed);
   if ($theresults) {
      $isamatch = "Valid";
   } else {
      $isamatch = "Invalid";
   }

   echo "Email address validation says $email is " . $isamatch;
}

?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="hidden" name="posted" value="true">
Enter your email address for validation:
<input type="text" name="email" value="name@example.com">
<input type="submit" value="Validate">
</form>
</body>
</html>

           
       








Related examples in the same category

1.Email validation Demo