pneudralics Posted April 27, 2009 Share Posted April 27, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/155877-solved-php-form-help-with-random-mysql-row-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 27, 2009 Share Posted April 27, 2009 http://www.phpfreaks.com/forums/index.php/topic,249639.msg1169928.html#msg1169928 You would need to use a session to pass the information between different pages or different requests of the same page. Quote Link to comment https://forums.phpfreaks.com/topic/155877-solved-php-form-help-with-random-mysql-row-error/#findComment-820479 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.