Validate email : Email Format « String « PHP

Validate email

   function validate_email($email) { 
      $regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,6})$";

      if (eregi($regexp, $email)) return 1;
         else return 0;

   if (isset($_POST['submit'])){
      echo "Hi ".$_POST['name']."!<br />";
      if (validate_email($_POST['email']))
         echo "The address ".$_POST['email']." is valid!";
         echo "The address <strong>".$_POST['email']."</strong> is invalid!";

<form action="index.php" method="post">
   Name:<input type="text" name="name" value="" />
   Email Address:<input type="text" name="email" value="" />
   <input type="submit" name = "submit" value="Go!" />

Related examples in the same category

1.A regular expression for e-mail string checking
2.Use regular to check email address