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:

Fire Tablet with Alexa, 7" Display, 8 GB, Magenta - with Special OffersFire Tablet with Alexa, 7" Display, 8 GB, Magenta - with Special Offers

Powerful, full-featured Fire tablet—with beautiful 7" IPS display, fast 1.3 GHz quad-core processor, rear and front facing cameras, and up to 20... Read More >

Fire Tablet with Alexa, 7" Display, 16 GB, Black - with Special OffersFire Tablet with Alexa, 7" Display, 16 GB, Black - with Special Offers

Powerful, full-featured Fire tablet—with beautiful 7" IPS display, fast 1.3 GHz quad-core processor, rear and front facing cameras, and up to 20... Read More >

Nest Cam Indoor security cameraNest Cam Indoor security cameraNest Cam helps you look after your home 24/7. Get alerts if something happens. And watch the action live in super clear 1080p HD.
Related Posts Plugin for WordPress, Blogger...