Results 1 to 3 of 3

Thread: Validating Email Address

  1. #1
    Hmmm bed
    Join Date
    Jul 2003
    Posts
    441
    Thanks
    5
    Thanked
    0 times in 0 posts

    Validating Email Address

    ok, I have developed a PHP script which sends a user there password, kinda a forgot password type thing. Just one thing i really cant work out. I need to validate the email address to ensure it is something@mydomain.com rather than just anyold email address, ie. it must contain mydomain.com at the end of it.

    so essentially all i need to do is grab the text from the email address field, trim the contents before that '@' and store this into a variable.

    then an if loop, if the variable = 'mydomain.com' then execute the script, else diaply an error message

    How would I go about doing this?

    Thanks

    Basher
    Last edited by Basher; 31-08-2003 at 05:38 PM.

  2. #2
    HEXUS.social member Agent's Avatar
    Join Date
    Jul 2003
    Location
    Internet
    Posts
    19,185
    Thanks
    739
    Thanked
    1,614 times in 1,050 posts
    PHP Code:
    <?
    //Email validation for a domain - written by Adrian Gurney
    // You need to pass a variable called "email" to the script, which will then check that variable

    // CONFIGURATION
    $domainname "mydomain.com";
    $findstring "@";

    //END CONFIGURATION

    $result strchr($email,$findstring);
    $result substr($result1);

    If (
    $result == $domainname) {

    ?>

    <html>
    <head>
    <title>Agents email validation</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    Put your script or file contents here - email is correct
    </body>
    </html>

    <?
    }
    else
    {
    ?>
    <html>
    <head>
    <title>Agents email validation</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    Put error message here - email isnt valid
    </body>
    <?
    }
    ?>
    Im going to start charging for this
    You need to pass the variable to the scrip with the name "email" - how you do this is upto you. I suggest you use POST.
    Last edited by Agent; 31-08-2003 at 07:54 PM.
    Quote Originally Posted by Saracen View Post
    And by trying to force me to like small pants, they've alienated me.

  3. #3
    Hmmm bed
    Join Date
    Jul 2003
    Posts
    441
    Thanks
    5
    Thanked
    0 times in 0 posts
    yup cheers, all sorted

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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