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, 16 GB, Blue - with Special Offers (Previous Generation - 5th)Fire Tablet with Alexa, 7" Display, 16 GB, Blue - with Special Offers (Previous Generation - 5th)

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 >

All-New Fire HD 8 Tablet with Alexa, 8" HD Display, 16 GB, Black - with Special OffersAll-New Fire HD 8 Tablet with Alexa, 8" HD Display, 16 GB, Black - with Special Offers

The all-new Fire HD 8 is the next generation of our best-reviewed Fire tablet ever--with up to 12 hours of battery life, a vibrant 8" HD display, ... Read More >

Acer Aspire E 15 E5-575-33BM 15.6-Inch Full HD Notebook (Intel Core i3-7100U Processor 7th Generation , 4GB DDR4,  1TB 5400RPM Hard Drive,  Intel HD Graphics 620, Windows 10 Home), Obsidian BlackAcer Aspire E 15 E5-575-33BM 15.6-Inch Full HD Notebook (Intel Core i3-7100U Processor 7th Generation , 4GB DDR4, 1TB 5400RPM Hard Drive, Intel HD Graphics 620, Windows 10 Home), Obsidian BlackAcer Aspire E5-575-33BM comes with these high level specs: 7th Generation Intel Core i3-7100U Processor (2.4GHz, 3MB L3 cache), Windows 10 Home, 15.6"... Read More >
Related Posts Plugin for WordPress, Blogger...