I'm creating a mock site and I'm having a hard time fixing it because I do not know how to validate numerous forms at once.
What happens:
- I have questions that are randomly selected by the database;
- These questions are inside a form with your alternatives;
- I want to correct them (leaving the page or not) by clicking on only
submit
- The simulation has 10 questions in all.
Note: I tried to use $_SESSION[]
and it worked, but only with one example.
I hope you have passed my idea, here is a snippet of code:
<div class="plataforma_layout_grade" data-reactid="42">
<div class="plataforma_layout_mestre" data-reactid="58">
<!--Criação de categoria de simulado-->
<div class="topico-mestre" data-reactid="59">
<h1 class="topico-titulo" data-reactid="60"><?php echo"$materia";?></h1>
</div>
<div>
<?php
$sql="select * from questoes where id_materia=$disciplina order by rand() limit 10";
$resultado=mysqli_query($conexao,$sql);
while ($vetor=mysqli_fetch_row($resultado)):
$_SESSION["id_questao"] = $vetor[0];
$id=$vetor[0];
$pergunta = $vetor[1];
$imagem = $vetor[2];
$A = $vetor[3];
$B = $vetor[4];
$C = $vetor[5];
$D = $vetor[6];
$E = $vetor[7];
$_SESSION["resposta"] = $vetor[8];
$resposta=$vetor[8];
?>
<div style="margin-left: 20px;margin-right: 20px; margin-top: 10px;">
<form method="POST" action="VALIDAR_SIMULADO.PHP" name="codigo" >
<fieldset >
<legend value="<?php echo'$id'; ?>">Cod. <?php echo"$id"; ?></legend>
<p style="margin-top: -2px;margin-bottom: 8px;" value="<?php echo'$id'; ?>"> <?php echo"$pergunta"; ?> <br>
<p><label>A) <input type="radio" name="alternativa" value="A"> <?php echo"$A"; ?></label></p>
<p><label>B) <input type="radio" name="alternativa" value="B"> <?php echo"$B"; ?></label></p>
<p><label>C) <input type="radio" name="alternativa" value="C"> <?php echo"$C"; ?></label></p>
<p><label>D) <input type="radio" name="alternativa" value="D"> <?php echo"$D"; ?></label></p>
<p style="margin-bottom:-2px;"><label>E) <input type="radio" name="alternativa" value="E"> <?php echo"$E"; ?></label></p>
</fieldset>
</div>
<?php endwhile; ?>
<input type="submit" name="corrigir" value="Corrigir">
</form>
</div>
</div>
</div>