Jump to content

[SOLVED] php form help with random mysql row error


pneudralics

Recommended Posts

I'm trying to make a php registration form. In the form I have one section where it randomly selects a question from the mysql table

$queryquestion = 'SELECT * FROM question ORDER BY RAND() LIMIT 1';
if ($resultquestion = mysql_query ($queryquestion)) {
while ($qrow = mysql_fetch_array ($resultquestion)) {
$question = $qrow['question'];
$answer = $qrow['answer'];
}
}

 

Then in the isset submit for the form I have the following to check if the answer is correct

if ($_POST['answer'] == "$answer") {
//good we move on
}
else {
echo "wrong answer";
}

 

The issue is when submit is click I always get the else statement for wrong answer. I'm thinking everytime I click submit a new random answer from the table gets compared to the post answer.

 

How can I solve this issue?

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.