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:

Electronics and Circuit Analysis Study Guide: Signal Transforms, Fourier, Laplace & Z transform, Transfer function, Electronic components, Analog & Digital Circuits (Mobi Study Guides)Electronics and Circuit Analysis Study Guide: Signal Transforms, Fourier, Laplace & Z transform, Transfer function, Electronic components, Analog & Digital Circuits (Mobi Study Guides)Boost Your grades with this illustrated study guide! You will use it from an undergraduate school all the way to graduate school and beyond.
Read More >
How to Diagnose and Fix Everything ElectronicHow to Diagnose and Fix Everything Electronic

 Master the Art of Electronics Repair In this hands-on guide, a lifelong electronics repair guru shares his tested techniques and invaluable insig... Read More >

How to Diagnose and Fix Everything ElectronicHow to Diagnose and Fix Everything ElectronicMaster the Art of Electronics Repair

In this hands-on guide, a lifelong electronics repair guru shares his tested techniques and invaluable ... Read More >

Related Posts Plugin for WordPress, Blogger...

Popularity: 41% [?]

Stop SOPA!

SOPA breaks our internet freedom!
Any site can be shut down whether or not we've done anything wrong.

Stop SOPA!