SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    psycho
    Join Date
    May 2000
    Location
    London
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How would i check if $var was something@something.com ?

    Cheers
    James

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    function check_email($emailtotest) {
    if (eregi("(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)", $emailtotest, $arr_vars) OR !eregi ("^.+\@(\[?)[-a-zA-Z0-9\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$", $emailtotest, $arr_vars)) {
    return false;
    }
    else {
    return true;
    }
    }


    Sample usage

    if (!check_email($email)) {
    print "Invalid Email";
    }
    }
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •