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:

All-New Fire HD 8 Tablet with Alexa, 8" HD Display, 16 GB, Marine Blue - with Special OffersAll-New Fire HD 8 Tablet with Alexa, 8" HD Display, 16 GB, Marine Blue - with Special Offers

The all-new Fire HD 8 is the next generation of our best-reviewed Fire tablet ever--with up to 12 hours of battery life, a vibrant 8" HD display, ... Read More >

USB Type C Cable, BrexLink USB C Cable 2 Pack (6.6ft) Nylon Braided Fast Charger Cord (USB 2.0) for Samsung Galaxy Note 8,S8,S8 Plus,LG G6 G5,V30,Google Pixel,Nintendo Switch,Macbook12",OnePlus2 (Grey)USB Type C Cable, BrexLink USB C Cable 2 Pack (6.6ft) Nylon Braided Fast Charger Cord (USB 2.0) for Samsung Galaxy Note 8,S8,S8 Plus,LG G6 G5,V30,Google Pixel,Nintendo Switch,Macbook12",OnePlus2 (Grey)LASTEST STANDARD POWERLINE USB-C to USB 2.0

Smart backup charging
Use this cable to charge your new MacBook, ChromeBook Pixel or other USB... Read More >
All-New Fire HD 8 Tablet with Alexa, 8" HD Display, 16 GB, Black - with Special OffersAll-New Fire HD 8 Tablet with Alexa, 8" HD Display, 16 GB, Black - with Special Offers

The all-new Fire HD 8 is the next generation of our best-reviewed Fire tablet ever--with up to 12 hours of battery life, a vibrant 8" HD display, ... Read More >

Related Posts Plugin for WordPress, Blogger...