PHP E-mail validation problem...

Discussion in 'PHP' started by jehzlau, Apr 17, 2007.

  1. #1
    I tried to validate my email in PHP after entering the email field in the HTML form...

    This is my email validator.

    if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$EmailAddress))
    Code (markup):
    It validates when the e-mail is incorrect, however it doesn't accept email address with dots, that is suppose to be valid. I don't know how to insert the dot or point to be a valid email address... for example:

    - Valid
    - Invalid

    Why did my validator doesn't accept an email with a dot in the name. I hope someone can answer this or correct my code :(
     
    jehzlau, Apr 17, 2007 IP
  2. Subikar

    Subikar Active Member

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #2
    <?php
    $email="subikar@myblogplanner.com";

    if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-
    ]+)*(\.[a-z]{2,3})$", $email) {

    echo "The e-mail was not valid";

    } else {

    echo "The e-mail was valid";

    }

    ?>


    Try this code this may help you out.
     
    Subikar, Apr 17, 2007 IP
  3. jehzlau

    jehzlau Active Member

    Messages:
    301
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    73
    #3
    it doesn't work still.. huhuhu i don't know why :(
     
    jehzlau, Apr 17, 2007 IP