hal1on
{ USER }
posts: 5
last: 13-Jul-2008
TITLE: Validating Email Addresses
DESCRIPTION: Make sure that submitted email address follows the correct format it should
Submitted: 19-Sep-2007 12:46:24 ( 1yrs 15w 5d 20h ago ) Language: PHP (*.php *.php4 *.php5 *.phtml)
Views: 401 Lines of Code: 19 LINES
Rating:
rate: star1
star2
star3
star4
star5
dstar1
dstar2
dstar3
dstar4
dstar5  ( rated! )
  { 0.00 / 5 }
Difficulty: Intermediate
Bookmark
/* Author: 
   Date: 19-09-2007
   Filename: 
   Description: 
   History: 
*/

$email_address_bad = "string which --isnt email format_";


/* Check if valid email address */
$regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*"
         ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*"
         ."\.([a-z]{2,}){1}$";


if(!eregi($regex,$email_address_bad)){
   echo "Email Address Invalid!";
}