0 Replies - 308 Views - Last Post: 21 May 2007 - 04:37 AM

#1 iamcenz  Icon User is offline

  • You wish you were my hand!
  • member icon

Reputation: 7
  • View blog
  • Posts: 2,443
  • Joined: 26-March 01

Validate an email address using regular expressions

Posted 21 May 2007 - 04:37 AM

Description: If you want a PHP script to verify an email address then use this quick and simple PHP regular expression for email validation. This is also case-insensitive, so it will treat all characters as lower case. It is a really easy way to check the syntax and format of an email address.
<?php

$email = "[email protected]";

if(eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $email)) {
  echo "Valid email address.";
}
else {
  echo "Invalid email address.";
}

?>


Is This A Good Question/Topic? 0
  • +

Page 1 of 1