Hi, I am writing a registration script. So far I have got a registration page. Once the user has registered, it sends a registration email and generates a 5 letter PIN code. The users details along with the PIN, are saved to a mysql database. The next step is for a user to enter the PIN that was emailed to them, before the script allows them to proceed. If they enter the wrong PIN, then a error message should be displayed instead.
This is what I have got. Currently it just shows a blank page once submitted. If I add an } else { print "PIN incorrect"; it just says the PIN is correct all the time. I have been stuck on this for the past day, any help is much appreciated.
if (isset($_POST['submit'])) {
$db = "moveitho_sitebuilder";
mysql_connect('localhost', 'moveitho_paul', 'test') or die(mysql_error());
mysql_select_db( $db) or die(mysql_error());
$username = mysql_real_escape_string($_POST['username']);
$gen_id = mysql_real_escape_string($_POST['gen_id']);
if ($result = mysql_query("SELECT username, gen_id FROM users WHERE username='$username' AND gen_id='$gen_id'")) {
if (mysql_num_rows($result)) {
echo "PIN matched";
}
}
}