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:

AmazonBasics AA Performance Alkaline Batteries (48 Count) - Packaging May VaryAmazonBasics AA Performance Alkaline Batteries (48 Count) - Packaging May VaryAnti-Leakage Protection, Holds in Power for up to 10 years in storage under normal use. Don't Get Caught In The Dark: The AmazonBasics Performance Alk... Read More >
All-New Kindle Oasis E-reader - 7" High-Resolution Display (300 ppi), Waterproof, Built-In Audible, 32 GB, Wi-Fi + Free Cellular ConnectivityAll-New Kindle Oasis E-reader - 7" High-Resolution Display (300 ppi), Waterproof, Built-In Audible, 32 GB, Wi-Fi + Free Cellular Connectivity

The All-New Kindle Oasis features our largest 7-inch 300 ppi display with a thin and light ergonomic design that lets you read more comfortably f... Read More >

Energizer AA Batteries, Double A Battery Max Alkaline (24 Count) E91BP-24Energizer AA Batteries, Double A Battery Max Alkaline (24 Count) E91BP-24Long-lasting power and innovation is what Energizer MAX is all about. Introducing our longest-lasting Energizer MAX battery yet. With our latest impro... Read More >
Related Posts Plugin for WordPress, Blogger...