Thread: help with row

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Sacramento
    Posts
    50
    Rep Power
    14
    Hi,

    I have a script that allows a user to enter their email address and have their password emailed to them. The problem is, I want to make sure that the email address they enter is valid, then send the email, if it's not, have an error response. Below is the code. It keeps displaying "Email Invalid" even when you enter a correct email.

    Thanks for any feedback

    <?


    $connection = mysql_connect (localhost, xxxx, xxxxx)
    or die ("Couldn't connect to server.");

    $db = mysql_select_db("DB", $connection)
    or die ("Couldn't select database.");

    $sql = "SELECT PASSWORD, FIRST_NAME
    FROM CUSTOMER
    WHERE EMAIL_ADDRESS='$EMAIL_ADDRESS'";

    // execute SQL query and get result
    $sql_result = mysql_query($sql,$connection)
    or die("Couldn't execute query.");

    //
    while ($row = mysql_fetch_array($sql_result)) {

    $password = $row["PASSWORD"];
    $name = $row["FIRST_NAME"];


    }


    $num = mysql_fetch_array($sql_result);

    if ($num == 1) {


    echo "<BR>Your password has been emailed to you!";


    mail("$EMAIL_ADDRESS", "Password Assitance",

    "Hello $FIRST_NAME!

    You have requested that your password be emailed to you.

    Your password is: $password

    Thank you!
    .",

    "From:from_emailn");

    } else if ($num == 0) {


    echo "<BR>This email address is not valid!";


    }

    ?>
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<
    The problem is, I want to make sure that the email address they enter is valid
    >>

    Here no need to validate the email address.bcoz if the user is not entering a valid email then he will not get his password.


    Try the following script.It will work for you..

    <?
    $connection = mysql_connect (localhost, xxxx, xxxxx)
    or die ("Couldn't connect to server.");

    mysql_select_db("DB", $connection);
    //select your database

    $sql = "SELECT PASSWORD, FIRST_NAME FROM CUSTOMER WHERE EMAIL_ADDRESS='$EMAIL_ADDRESS'";


    $sql_result = mysql_query($sql,$connection);

    //issuse sql query


    $row = mysql_fetch_array($sql_result);

    if (mysql_num_rows($sql_result) == 1) {
    //yes that email was right..

    $password = $row["PASSWORD"];
    $name = $row["FIRST_NAME"];

    $message="Hello $FIRST_NAME!n";
    $message.="You have requested that your password be emailed to you.n";
    $message.="Your password is: $passwordn";
    $message.="Thank you!.";

    mail($EMAIL_ADDRESS,"Password Assitance",
    $message,"From: youremailn Reply-to:youremailn");


    echo "<BR>Your password has been emailed to you!";

    }else{
    //No record so.give error message.
    echo "<BR>This email address is not valid!";
    exit;
    }
    ?>

    Good Luck!!!


    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Sacramento
    Posts
    50
    Rep Power
    14
    Thank you!!

Similar Threads

  1. div style="overflow: scroll;"
    By slydero in forum HTML Programming
    Replies: 8
    Last Post: October 26th, 2004, 09:54 AM
  2. row not inserting at end of table
    By sweetpotatoe in forum PHP Development
    Replies: 9
    Last Post: December 15th, 2003, 01:07 PM
  3. <THEAD> not printing across multiple pages
    By allanmcc in forum HTML Programming
    Replies: 2
    Last Post: September 29th, 2003, 08:47 PM
  4. Creating An Excel Spreadsheet From Web Form Data
    By MGarde in forum ASP Programming
    Replies: 5
    Last Post: May 19th, 2003, 09:22 PM

IMN logo majestic logo threadwatch logo seochat tools logo