Check multiple Radio type input in one simulation

0

Well, I'm creating a website and I need to validate the input radio fields. I thought about using JS, but it did not work. As said in the topic, there are several fields that I need to validate. follow the code that I have to validate:

    <h1 class="topico-titulo" ><?php echo"$nome";?></h1>                
                                <?php 
    $sql="select * from questoes where id_materia=$materia order by rand() limit 10";
                                    $resultado=mysqli_query($conexao,$sql);?>
                                    <div style="margin-left: -28px;margin-right: 10px; margin-top: 10px;" >


 <form name="simulado" action="correcao.php" method="post">
 <ul style="list-style-type:none;">
    <?php $i = 0; ?>

   <?php while($vetor = mysqli_fetch_row($resultado)): ?>

 <?php list($id, $pergunta, $imagem, $a, $b, $c, $d, $e, $resposta, $resolucao) = $vetor; ?>

<li> <fieldset  >
  <legend >Questão <?= $i+1; ?></legend>
 <legend > <i>cod.<?= $id; ?></i> </legend>
  <p > <?= $pergunta; ?></p>
  <?php if(!empty($imagem)) { $arquivo = substr($imagem, -3); if($arquivo=='jpg'){?>
  <center>
  <p > <img src="Imagens/<?php echo $imagem; ?>" width="80%" heigth="70%"/>     </p>
  <?php }}?></center>
  <?php $_SESSION['pergunta'.$i]=$pergunta; ?>
  <?php $_SESSION['resolucao'.$i]=$resolucao; ?>
         <input type="hidden" name="questao[<?= $i; ?>]"    value"<?php echo $pergunta; ?>">
         <input type="hidden" name="id[<?= $i; ?>]"          value="<?php echo $id; ?>">
         <input type="hidden" name="resposta[<?= $i; ?>]"    value="<?php echo $resposta; ?>">
         <ul style="list-style-type:none;margin-left:-6%;">
  <li> <label><input type="radio"  name="alternativa[<?= $i; ?>]" value="A"> <?= $a; ?></label><br/> </li>
  <li> <label><input type="radio"  name="alternativa[<?= $i; ?>]" value="B"> <?= $b; ?></label><br/></li>
  <li> <label><input type="radio"  name="alternativa[<?= $i; ?>]" value="C"> <?= $c; ?></label><br/></li>
  <li> <label><input type="radio"  name="alternativa[<?= $i; ?>]" value="D"> <?= $d; ?></label><br/></li>
  <li> <label><input type="radio"  name="alternativa[<?= $i; ?>]" value="E"> <?= $e; ?></label></li>
  </ul>
 </fieldset></li> 

 <?php $i++; ?>

  <?php endwhile; ?>

  <input type="submit" name="corrigir" value="Corrigir Simulado">

   </form>
   </div>
   </div>

Any attempt to help will be valid and acknowledged, if my purpose is not clear, please comment and I will exemplify and clarify any doubts.

Right now, very grateful!

    
asked by anonymous 16.03.2017 / 06:12

1 answer

0

You can solve this problem by using the HTML5 attribute of HTML5 , you only need to required that others in the same group will adopt the same.

See similar question in global stackoverflow

    
16.03.2017 / 19:28