PHP Email Validation

August 20, 2007 by  
Filed under Code Snippets

Note to self, use this for email validation:

function isEmail($email)
{
if(ereg("^([a-zA-Z0-9_\-\.]+)@
((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|
(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $email))
return 1; // If email address is valid
else
return 0;
}

Minus all the spaces in the ereg function.

Related Products:

Nintendo New 3DS XL - Super NES Edition + Super Mario Kart for SNESNintendo New 3DS XL - Super NES Edition + Super Mario Kart for SNESThe New Nintendo 3DS XL system combines next-generation portable gaming with super-stable 3D technology and added control features. Take 3D photos, co... Read More >
Bose QuietComfort 35 (Series II) Wireless Headphones, Noise Cancelling - BlackBose QuietComfort 35 (Series II) Wireless Headphones, Noise Cancelling - BlackHow did Bose make its world-class noise cancelling headphones even better? It now allows you to adjust the level of noise cancellation on the new Quie... Read More >
Nintendo Switch - Neon Blue and Red Joy-ConNintendo Switch - Neon Blue and Red Joy-Con

Introducing Nintendo Switch, the new home video game system from Nintendo. In addition to providing... Read More >

Related Posts Plugin for WordPress, Blogger...