PLEASE HELP ME!!! PHP!!!!?

myscranton

New member
I have been trying for HOURS to create a login page that asks you to answer a security question. Everything seems right but it won't work and I have no clue what to do! I can't figure this out and I really need help! PLEASE HELP!

<?php
$qry4 = "SELECT COUNT(*) FROM {$prefix}_Security_Questions";
$result4 = mysql_query($qry4);
$number_of_questions = mysql_result($result4, 0);
$question_id = rand(1, $number_of_questions);
$qry5 = "SELECT * FROM {$prefix}_Security_Questions WHERE question_id = '$question_id'";
$result5 = mysql_query($qry5);
$row5 = mysql_fetch_array($result5);
$question = $row5['question'];
$answer = $row5['answer'];

if ($answer != $_POST['security_question'])
{
$errors[] = "You answered the security question incorrectly!";
}
else
{
$login_username = stripslashes($login_username);
$day = time() + 60*60*24;
setcookie(Super, $login_username, $day);
setcookie(Super_Password, $login_password, $day);
header("Location: /login.php?success=true");
}

?>

<tr>
<td width="250">
<label style="font-family:Arial; font-size:18px; text-align:left; color:white; cursor:pointer" onmouseover="this.style.color = '#FF4400'" onclick="document.form.security_question.focus()" onmouseout="this.style.color = 'white'">Security Question:</label><br>
<span class="question"><?php echo $question; ?></span>
</td>
<td width="500" valign="top">
<input type="text" name="security_question" onfocus="this.style.backgroundColor = '#CCDDDD'" onblur="this.style.backgroundColor = 'white'" size="30">
</td>
</tr>

This is a summary of my code. I have written to the screen my variable to make sure they are set correctly and they are. I keep getting the message that I didn't answer the question correctly but the answer is right and the query is correct. WHAT IS WRONG?!
 
Back
Top