Hello, I'm developing an online proofing system as follows:
Thequestionscomestraightfromthedatabase(MYSQL)andsoIputtheproofshowingquestionbyquestion,whentheusermarkstheanswerandclicks"Next" advances to the next question.
My question is: how do I store in a single variable, be it array or anything, all the answers to the test?
This is the code for my form:
<?php
require_once('validasessao.php');
$codigo = $_GET['codigo'];
include_once("./classes/conexao.class.php");
include_once("./classes/avaliacoes.class.php");
include_once("./classes/QuestoesDisciplinas.class.php");
$conn = new Conexao();
$questaoDisciplina = new QuestoesDisciplinas($codigoDisciplina, $codigoQuestao);
$avaliacao = new Avaliacoes($codigoAvaliacao, $codigoDisciplina, $dataAvaliacao, $horaInicioAvaliacao, $horaTerminoAvaliacao, $situacaoAvaliacao);
#localizar a avaliação
if($avaliacao->localizarAvaliacao($codigo)){
#pegar os códigos
$codigoAvaliacao = $avaliacao->getCodigoAvaliacao();
$codigoDisciplina = $avaliacao->getCodigoDisciplina();
#buscar as questões
$res = $questaoDisciplina->buscarQuestoesDisciplina($codigoDisciplina);
$array = mysql_fetch_assoc($res);
if($_POST['numeroQuestao'] == 0) {
$numeroQuestao = 1;
} else {
$numeroQuestao = $_POST['numeroQuestao'];
$respostaUsuario = $_POST['respostaUsuario'];
#$respostas[$numeroQuestao-1] = $respostaUsuario;
#print_r($respostas);
}
if($numeroQuestao <= $array['quantidadeQuestoesDisciplina']){
<form name = "prova" id = "prova" action = "?pag=provas-p.php&codigo=<?php echo $codigo ?>" method = "POST">
<table>
<tr>
<td><b>Questao <?php echo $numeroQuestao . "/". $array['quantidadeQuestoesDisciplina'] ?></b></td>
</tr>
<tr>
<td><?php echo $array['descricaoQuestao'] ?></td>
</tr>
<tr>
<td>A) <input type = "radio" name = "respostaUsuario" value = "A"><?php echo $array['descricaoResposta1Questao']?></td>
</tr>
<tr>
<td>B) <input type = "radio" name = "respostaUsuario" value = "B"><?php echo $array['descricaoResposta2Questao']?></td>
</tr>
<tr>
<td>C) <input type = "radio" name = "respostaUsuario" value = "C"><?php echo $array['descricaoResposta3Questao']?></td>
</tr>
<tr>
<td>D) <input type = "radio" name = "respostaUsuario" value = "D"><?php echo $array['descricaoResposta4Questao']?></td>
</tr>
<tr>
<td>E) <input type = "radio" name = "respostaUsuario" value = "E"><?php echo $array['descricaoResposta5Questao']?></td>
</tr>
<tr>
<td><br></td>
</tr>
$numeroQuestao++;
<tr>
<td>
<input type = "hidden" name = "numeroQuestao" id = "numeroQuestao" value = "<?php echo $numeroQuestao ?>">
<input type = "submit" name = "enviar" id = "enviar" value = "Próximo">
</td>
</tr>
</table>
</form>
I just want to save the user's response, but I can not do it.