Hi all,
I have a form, which is created from a loop getting results from a database (Below).
The radio buttons are created in the loop. When the user hits submit the code checks that each question was answered
(Each question has multiple answers. Hence the need for radio buttons).
This is my checking code:
if (!$answers)
{
echo '<h1>Please answer all of the questions<br />';
echo '<a href="#" onClick="history.go(-1)">Go Back</a></h1>';
exit;
}
Even when each question is answered it still displays this message. How can I fx this? Thanks.
echo '<form id="FormName" action="user_answers.php" onsubmit="return confirm('Are you Sure?');" method="post" name="FormName">';
echo 'Enter Your Name: <input type="text" name="name" title="Enter Your Full Name"><br /><br />';
foreach ($answers as $key => $value)
{
echo $key . '. ' . $questions[$key] . '<br>';
foreach ($value as $answer)
{
echo $answer . '<input type="radio" name="answers[' . $key . ']" value="' . $answer_key . '"> <br>';
}
echo '<br>';
}
echo '<input type="submit" name="submit" value="Submit Quiz">';
echo '</form>';