Email address validation in PHP

Discussion in 'PHP' started by virtualmisc, Feb 15, 2010.

  1. #1
    Hello friends


    I have my website completely made in PHP. But I m stuck in the Email address validation. How can i do that with PHP.


    Thanks
     
    virtualmisc, Feb 15, 2010 IP
  2. chadsmith

    chadsmith Peon

    Messages:
    82
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try:

    function is_email($str){
    	return preg_match("/^[a-z0-9,!#\$%&'\*\+\/=\?\^_`\{\|}~-]+(\.[a-z0-9,!#\$%&'\*\+\/=\?\^_`\{\|}~-]+)*@([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+([a-z]{2}|com|org|net|gov|mil|biz|tel|info|mobi|name|aero|jobs|museum)$/",$str);
    }
    PHP:
    The email will have to be lowercase as well so make sure you pass it through strtolower() first.
     
    chadsmith, Feb 15, 2010 IP