Hi to everybody!
I have a problem with a sort of quiz page I'm making in PHP with MySQL.
I have two pages, let's say page1.php and page2.php. Page1.php queries a database to build the quiz, pulling the questions and the possible choices from the datas in the database. Then, using POST, it sends the form to page2.php, which controls the datas and shows the results.
Unfortunately, page2.php shows only the questions, the corrected answer but not the answers made by the user.
Could someone tell me why?
Here's some pieces of code I think "responsible":
--- page1.php ---
for ($c = 0; $c <= 3; $c++) // choices for every lineare per riga: 4
{
echo "<td>";
echo "<input type=\"radio\" name=$given_answer[$a] value=$possible_choices[$c]>";
echo $possible_choices[$c];
echo "</td>";
}
Note: of course I put a session_start(); command in both pages, to make them work.
These are some lines of page1.php:
$SESSION['NUMBER_OF_QUESTIONS] = NUMBER_OF_QUESTIONS; // remembers the total number of questions
$SESSION['question'] = $question; // remembers the question
$SESSION['given_answer'] = $given_answer; // remembers the answer given by the user
$SESSION['rigth_answer'] = $rigth_answer; // remembers the right answers
So every information is stored in $_SESSION, but only NUMBER_OF_QUESTIONS, $question and $rigth_answer are "remembered", not $given_answer
Please help!