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:

Kindle Paperwhite E-reader - Black, 6" High-Resolution Display (300 ppi) with Built-in Light, Wi-Fi - Includes Special OffersKindle Paperwhite E-reader - Black, 6" High-Resolution Display (300 ppi) with Built-in Light, Wi-Fi - Includes Special Offers

Featuring our highest resolution display, hand-crafted font Bookerly, and a new typesetting engine for even more beautiful rendering of pages. Our... Read More >

Energizer AAA Batteries, Triple A Battery Max Alkaline (24 Count) E92BP-24Energizer AAA Batteries, Triple A Battery Max Alkaline (24 Count) E92BP-24

Long-lasting power and innovation is what the Energizer MAX family is all about. Meet our longest-lasting AA and AAA Energizer MAX batteries yet. T... Read More >

Intel Core i7-8700K Desktop Processor 6 Cores up to 4.7GHz Turbo Unlocked LGA1151 300 Series 95W BX80684i78700KIntel Core i7-8700K Desktop Processor 6 Cores up to 4.7GHz Turbo Unlocked LGA1151 300 Series 95W BX80684i78700KOutstanding gaming experiences extend beyond personal gameplay to your entire gaming community. Share those experiences by live-streaming or recording, editing, and posting your epic highlights.
Related Posts Plugin for WordPress, Blogger...