PHP Registration with Email Verification Help

Discussion in 'PHP' started by jgab, Oct 2, 2012.

  1. #1
    Hi ,

    i'm new to php. i'm creating a signup form with email verification (PHPmailer) everything seems to work except when the user confirm the email, their information does not save to the database , so they can't login to their account. the error is with the INSERT INTO customer part. can someone help me? thanks


    <?php
    if (isset($_GET["passkey"]))
    {
    $confirm = $_GET["passkey"];
    $con = mysql_connect("localhost","root");
    if (!$con)
    echo(mysql_error());
    else
    { mysql_select_db("dbhotel",$con);
    $sql = "SELECT * FROM temp WHERE ConfirmCode = '" . $confirm . "'";
    $rs = mysql_query($sql,$con);
    if (mysql_num_rows($rs) == 1)
    {
    $rows = mysql_fetch_assoc($rs);

    $sql = "INSERT INTO customers(FName,LName,Title,Address,Phone,Email,Password) VALUES ('". $rows["FName"] . "','" . $rows["LName"] . "','" . $rows["Title"] . "','" . $rows["Address"] . "','" . $rows["Phone"] . "','" . $rows["Email"] . "','" . $rows["Password"]."')";
    mysql_query($sql,$con);

    $sql = "DELETE FROM temp WHERE ConfirmCode = '" . $confirm . "'";
    mysql_query($sql,$con);
    echo "Congratulations " . $rows["Title"] ." ". $rows["FName"] ." ". $rows["LName"] . ", you are now a member!";
    }
    else
    {
    echo "Sorry, we are unable to process your request at this moment. Please try again later.";
    }
    }
    mysql_close($con);
    }
    else
    {
    echo "You do not have enough permissions to access this page.";
    }
    ?>
     
    jgab, Oct 2, 2012 IP
  2. plussy

    plussy Peon

    Messages:
    152
    Likes Received:
    5
    Best Answers:
    9
    Trophy Points:
    0
    #2
    sorry to ask but did you do any debugging via mysql_error()?
     
    plussy, Oct 2, 2012 IP
  3. scottlpool2003

    scottlpool2003 Well-Known Member

    Messages:
    1,708
    Likes Received:
    49
    Best Answers:
    9
    Trophy Points:
    150
    #3
    Are you posting these variables?

    Before inserting them?

    If so, try echoing them out individually to make sure they're all posting ok.
     
    scottlpool2003, Oct 3, 2012 IP
  4. RaPeRbOy

    RaPeRbOy Active Member

    Messages:
    425
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    90
    #4
    What error it`s displayed?
     
    RaPeRbOy, Oct 3, 2012 IP
  5. Drent123

    Drent123 Peon

    Messages:
    105
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Drent123, Oct 3, 2012 IP
  6. kevinn13

    kevinn13 Greenhorn

    Messages:
    24
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    11
    #6
    Either SQL error or rows mismatch

    Do you have a SQL Manager on your account can you dump this into the database via that interface

    INSERT INTO customers(FName,LName,Title,Address,Phone,Email,Password) VALUES ('". $rows["FName"] . "','" . $rows["LName"] . "','" . $rows["Title"] . "','" . $rows["Address"] . "','" . $rows["Phone"] . "','" . $rows["Email"] . "','" . $rows["Password"]."')";
    mysql_query($sql,$con);

    If not then what error is displayed?
     
    kevinn13, Oct 5, 2012 IP
  7. real_person

    real_person Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    First, You need to secure incoming data

    The valid code:
    Second, You don't need to spicife the SQL's connection link

    The valid code:
    Thirty, Mysql results may be more than 1
    INSTEAD OF
    Forty, The single quates should be inside the double quates
    In finally you get a readable&workable code

    Here you go, This code i've tested it
     
    real_person, Oct 5, 2012 IP