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 >

Fire TV Stick with Alexa Voice Remote | Streaming Media PlayerFire TV Stick with Alexa Voice Remote | Streaming Media Player

Fire TV Stick connects your HDTV to a world of online entertainment. Stream a massive selection of movies and TV episodes from Netflix, Amazon Vid... Read More >

Beam Electronics Universal Smartphone Car Air Vent Mount Holder Cradle Compatible with iPhone X 8 8 Plus 7 7 Plus SE 6s 6 Plus 6 5s 5 4s 4 Samsung Galaxy S6 S5 S4 LG Nexus Sony Nokia and More…Beam Electronics Universal Smartphone Car Air Vent Mount Holder Cradle Compatible with iPhone X 8 8 Plus 7 7 Plus SE 6s 6 Plus 6 5s 5 4s 4 Samsung Galaxy S6 S5 S4 LG Nexus Sony Nokia and More…Quick Release Button: Press button on back of unit to slide open and then take out mobile phone. Press the arms on both side to clamp mobile phone aga... Read More >
Related Posts Plugin for WordPress, Blogger...