pcw Posted February 24, 2009 Share Posted February 24, 2009 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 More sharing options...
br0ken Posted February 24, 2009 Share Posted February 24, 2009 Where you have the 'print "Yes it worked"' simply remove this and add the following: header("location: login.php"); This will redirect the user to the login page. On this page add your login form html code. Link to comment https://forums.phpfreaks.com/topic/146757-mysql-pin-match-help/#findComment-770472 Share on other sites More sharing options...
pcw Posted February 24, 2009 Author Share Posted February 24, 2009 That doesnt seem to work. I have messed about with the code, and the script displays the login form whether the PIN is correct or not. I think it is the actual mysql query code that is wrong. Does anyone know how I can fix this? Link to comment https://forums.phpfreaks.com/topic/146757-mysql-pin-match-help/#findComment-770504 Share on other sites More sharing options...
pcw Posted February 24, 2009 Author Share Posted February 24, 2009 can anybody help on this one? Link to comment https://forums.phpfreaks.com/topic/146757-mysql-pin-match-help/#findComment-770520 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.