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:

SanDisk 64GB Ultra SDXC UHS-I Memory Card SDSDUNC-064G-GN6INSanDisk 64GB Ultra SDXC UHS-I Memory Card SDSDUNC-064G-GN6INTwice as fast as ordinary SDHC and SDXC cards to take better pictures and Full HD videos with your compact to mid-range point and shoot cameras and ca... Read More >
Fire 7 Kids Edition Tablet, 7" Display, 16 GB, Blue Kid-Proof CaseFire 7 Kids Edition Tablet, 7" Display, 16 GB, Blue Kid-Proof Case

Powerful, full-featured Fire 7 tablet--with 1 year of Amazon FreeTime Unlimited and a Kid-Proof Case--for a savings of up to $129--plus a 2-year w... Read More >

Nintendo Switch Joy-Con Charging DockNintendo Switch Joy-Con Charging DockThe Joy-Con Charging Dock is the easiest solution for charging your Nintendo Switch Joy-Con Controllers. Charge 4 Joy-Con Controllers at a time for multiple players, or keep an extra pair charged for single players to switch out.
Related Posts Plugin for WordPress, Blogger...