Search Marketing

   
   

Using PHP to Check the Formatting of Email Addresses

Fri May 02, 2008 10:04 pm
<<    
Comments: 0 Views: 331

The below example makes use of PHP and Regular Expressions to breakdown what someone might type into an email field and make sure that it fits the general format.

$email = "test@test.com";

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

To learn more about using regular expressions this tutorial has some good information for beginners.

Comments
Name:
*
URL: http: (ex. cnn.com)
Comment:
*
Number:
Math (15 + 4)
* required
SubCategories
Regular Expressions

© 2019 Christonium LLC

Christonium.com
|
Terms of Use
|
Privacy
ccc