Jump to content

mysql pin match help


pcw

Recommended Posts

I am just writing a registration and login script. After registration, I would like the user to enter the PIN number emailed to them, to verify that they have supplied the correct email address.

 

The script already creates a random 5 letter password, writes it to the database, and emails it to the user.

 

I am having a bit of trouble working out how to show a login form if the PIN number matches what is in the database, and an error message if it doesnt.

 

Any help on how to solve this would be much appreciated. Below is what I have got so far.

 

function pin_chk() {

 

$username = $_POST['username'];

$pin = $_POST['pin'];

 

 

$query = sprintf("SELECT username, gen_id FROM users WHERE username='%s' AND gen_id='%s'",

    mysql_real_escape_string($username),

    mysql_real_escape_string($pin));

 

$result = mysql_query($query);

 

if (!$result) {

    $message  = 'Invalid query: ' . mysql_error() . "\n";

    $message .= 'Whole query: ' . $query;

    die($message);

 

print "Yes it worked"; # This is where the login form goes

 

} else {

 

print "No it didnt"; # This is the error message

}

}

 

Please help, I really cant work this one out  :)

Link to comment
https://forums.phpfreaks.com/topic/146757-mysql-pin-match-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.