Cadastrar um checkbox no mysql pelo PHP
Prezados colegas.
Tenho uma página em HTML que tem alguns checkboxes, e gostaria de gravar sua marcação no mysql pelo PHP. Já cheguei a fazer a estrutura inicial, mas o mesmo só indica erro ao executar a ação, será q vcs podem dar uma olhada no codigo para me falarem oq está errado!?
Obrigado
HTML
<HTML><HEAD> <TITLE>Equipamentos e software</TITLE></HEAD><BODY><table border=0> <form method="POST" action="inclui.php"> <input type="hidden" name="operacao" value="incluiequip"> <tr> <td><input type=checkbox name="equip[]" value=0>2130  Serial:<input type=text name="serial2130"></td> </tr> <tr> <td><input type=checkbox name="equip[]" value=0>9210  Serial:<input type=text name="serial9210"></td> </tr> <tr> <td><input type=checkbox name="equip[]" value=0>9800  Serial:<input type=text name="serial9800"></td> </tr> <tr> <td><input type=checkbox name="equip[]" value=0>SonicScan  Serial:<input type=text name="serialSonicScan"></td> </tr> <tr> <td><input type=checkbox name="equip[]" value=0>4500  Serial:<input type=text name="serial4500"></td> </tr> <tr> <td><input type=checkbox name="equip[]" value=0>5200  Serial:<input type=text name="serial5200"></td> </tr> <tr> <td><input type=checkbox name="equip[]" value=0>8130  Serial:<input type=text name="serial8130"></td> </tr> <input type="submit" name="submit" value="Vai!"> </form></table></BODY></HTML>
PHP
else if ($operacao=="incluiequip") { if (isset($_POST['equip[]'])) { $value = ''; foreach($_POST['equip[]'] as $value); $sql = mysql_query("INSERT INTO equipamentos (viteumtrinta,noventaedoisdez,termografia,sonicscan,online,trivector,ultraspe) VALUES ('$value')"); $linha = mysql_affected_rows(); } if ($linha==1) { echo "Cadastrado com sucesso <br>"; } else { echo "Problema!"; } }Discussão (15)
Carregando comentários...