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:

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 >
Practical Electronics for Inventors, Fourth EditionPractical Electronics for Inventors, Fourth Edition

A Fully-Updated, No-Nonsense Guide to Electronics

Advance your electronics knowledge and gain the skills necessary to develop and construct y... Read More >

Assurant 3-Year Portable Protection Plan ($0-$49.99)Assurant 3-Year Portable Protection Plan ($0-$49.99)3 YR Portable Protection Plan ($0-$49) 3 year Date of Purchase service plan. Coverage for mechanical and electrical failures are covered after the manufacture's warranty expires; Free 2-way shipping for repairs; Fully transferable; cancel anytime, full refund in the first 30 days; No deductibles
Related Posts Plugin for WordPress, Blogger...