Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/09/2015, 20:55
ycaires
 
Fecha de Ingreso: septiembre-2015
Ubicación: caracas
Mensajes: 75
Antigüedad: 9 años, 5 meses
Puntos: 0
data checkbox php y mysql

Buenas noches tengo un formulario con un checkbox y necesito que la data se cargue en la base de datos pero cuando el usuario hace el check se carga la ùltima opciòn seelccionada

ESTE ES EL FORMULARIO

<html>
<head>
<title>SISTEMA 2</title>
</head>
<body>
<center>
<h1>SISTEMA 2</h1>
<table border="0">
<form action="agregar.php" method="post">
<tr>
<td>cedula</td>
<td><input type="text" name="txtcedula"></td>
</tr>
<tr>
<td>Pasatiempo</td>
<td>
<input type="checkbox" name="pasa1" value=1>beseball<br>
<input type="checkbox" name="pasa1" value=2>football<br>
<input type="checkbox" name="pasa1" value=3>chess<br>
<input type="checkbox" name="pasa1" value=4>basketball<br>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Guardar">
</td>
<td>
<input type="reset" value="Limpiar">
</td>
</tr>
</form>
</table>

<a href="menu.html">volver al menu Princial</a>
</center>
</body>
</html>

ESTE ES EL PHP DONDE ESTA EL ERROR QUE ENVIA LA DATA A LA BASE DE DATOS

<?php

include("conexion.php");

$cedx=$_POST["txtcedula"];


if($_POST["pasa1"]==1) $pa1x=1;
else $pa1x=0;

if($_POST["pasa1"]==2) $pa2x=2;
else $pa2x=0;

if($_POST["pasa1"]==3) $pa3x=3;
else $pa3x=0;

if($_POST["pasa1"]==4) $pa4x=4;
else $pa4x=0;

$sql="insert into alu values($cedx,$pa1x,$pa2x,$pa3x,$pa4x)";

//echo $sql;exit(0);

$result=mysql_query($sql,$conn);
?>
<html>
<body>
<center>
<h1>datos agregados con exito</h1>
<br>
<a href="menu.html">volver al menu principal</a>
</center>
</body>
</html>

Si alguien me puede ayudar muchas gracias