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:

Nintendo Switch - Gray Joy-ConNintendo Switch - Gray Joy-Con

Introducing Nintendo Switch, the new home video game system from Nintendo. In addition to providin... Read More >

Ring Wi-Fi Enabled Video Doorbell in Satin Nickel, Works with AlexaRing Wi-Fi Enabled Video Doorbell in Satin Nickel, Works with Alexa

At Ring, our mission is simple: To reduce crime in neighborhoods. And by putting the power of home security in your hands, we’re making that miss... Read More >

Samsung 970 EVO 500GB - NVMe PCIe M.2 2280 SSD (MZ-V7E500BW)Samsung 970 EVO 500GB - NVMe PCIe M.2 2280 SSD (MZ-V7E500BW)Samsung’s 970 EVO continues to lead industry standards with V-NAND technology for reliable and superior performance. Accelerate into next-gen comput... Read More >
Related Posts Plugin for WordPress, Blogger...