2
Good afternoon,
I need to pass the values selected from a checkbox to a page through a form by Post and save them in a database, but I’m not getting, could help me?
Follows the code:
Form:
<form class="form-horizontal" method="POST" action="operacoes.php?action=GeraProva">
<div align="center" style="margin-top:200px;">
<div class="control-group">
<label class="labelTrab" for="txtNmMod">Módulo:</label>
<input id="txtNmDis" name="txtNmMod" type="text" class="input-mini" value="<?php echo $dsmodulo ?>" disabled="disabled"><br/>
<?php if($valProvas > 0) {?>
<label class="labelTrab" for="txtNrProva">Prova:</label>
<input id="txtNmDis" name="txtNrProva" type="text" class="input-mini" value="<?php echo $cdprova ?>" disabled="disabled"><br/>
<?php }?>
<table border='1'>
<tr>
<th>Selecionar</th><br/>
<th>ID</th><br/>
<th>Descrição</th><br/>
<th>Disciplina</th><br/>
</tr>
<?php
while($row = mysql_fetch_array($var))
{
$ar = $row["cod_disc"];
$aux = mysql_query("select nome_disc from tb_disciplinas where cod_disc = '$ar'");
$ftc1 = mysql_fetch_array($aux);
$nmdisc = $ftc1["nome_disc"];
$id = $row["cdpergunta"];
echo "<tr>";
echo "<td><input type='checkbox' name='checkPerg[]'/></td><br/>";
echo "<td>" . $row["cdpergunta"] . "</td><br/>";
echo "<td>" . $row["dspergunta"] . "</td><br/>";
echo "<td>" . $nmdisc . "</td><br/>";
echo "</tr>";
}
?>
</table>
</div>
<div style="margin-top:5px;">
<button id="singlebutton" name="btnPesquisa" class="btn btn-primary">Gerar Prova</button>
<a href="lista.php?action=EnviaDadosLista"><input type="button" id="singlebutton" name="btnVoltar" class="btn btn-primary" value="Voltar"/>
</div>
</div>
</form>
PHP:
$id = $_GET['v'];
$nmodulo = $_POST['txtNmMod'];
if(isset($_POST['checkPerg']))
{
echo "<script>alert('Pera!')</script>";
if(count($_POST['checkPerg']) > 0)
foreach($_POST['checkPerg'] as $item)
echo $item."<br/>";
}
if(isset($_POST['txtNrProva']))
{
$cdprova = $_POST['txtNrProva'];
}
else
{
//echo "<script>alert('Pode Voltar!')</script>";
echo "<meta http-equiv='refresh' content='0, url=lista.php?v=$nmodulo&r=$nrqts&action=GeraLista'>";
}
You could help me in this situation?
Thank you in advance.
What’s the matter?
– Maicon Carraro