Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/06/2015, 13:20
cesarcb95
 
Fecha de Ingreso: junio-2015
Mensajes: 26
Antigüedad: 8 años, 11 meses
Puntos: 0
COMO enviar datos de Menu multiple a fila de la tabla

Apenas estoy comensando con base de datos en formularios estoy practicando un poco pero tengo una pequeña confucion e creado el formulario y en la parte de categorias le coloque un menu de seleccion multiple y cuando provee el formulario y me llevo con la sorpresa que cuando selecciono varias opciones en la base de datos no me registra las dos seleccionadas me aparece el Numero 2 y cuando selecciono uno si aparece la opcion que puedo hacer hay ayudaaaaaaaa porfavor
el codigo es el siguiente:

<html>
<head>
<title>Formulario de registro</title>

<body>
<h1>Formulario de registro</h1>
<h3>Todos los campos son requeridos(*).</h3>
<form action="registrar.php" method="post">
<table>
<tr>
<td>
*Nombre:
</td>
<td>
<input type="name" name="Nombre" />
</td>
<td>
*Apellido:
</td>
<td>
<input type="name" name="Apellido" />
</td>
<td>
*Cedula:
</td>
<td>
<input type="number" name="Cedula" />
</td>
<td>
*Numero de piloto:
<input type="text" name="Numerodepiloto" />
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>*Categorias: </td>
<td><select name="Categorias" size="4" multiple="MULTIPLE">
<option value="rx115" selected>RX115</option>
<option value="rx115 huila">RX115 HUILA</option>
<option value="200 aire">200 AIRE</option>
<option value="200 novatos">200 NOVATOS</option>
</select></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<input type="submit" value="enviar"/>
</form>
</body>

</html>


PHP QUE HACE LA CONECCION Y ENVIO ALA BASE DE DATOS

Código PHP:
Ver original
  1. <?php
  2. // Crear connection
  3. $servername = "";
  4. $username = "l";
  5. $password = "";
  6. $dbname = "";
  7.  
  8. $conn =new mysqli('','','','');
  9. echo "Guardado correctamente.";
  10. echo "<a href='index.php'>Volver al menu </a>";
  11.  
  12.  $Nombreregistrado = $_POST["Nombre"];
  13.  $Apellidoregistrado = $_POST["Apellido"];
  14.  $Cedularegistrada = $_POST["Cedula"];
  15.  $Numerodepilotoregistrado = $_POST["Numerodepiloto"];
  16.  $Categoriasregistrado = $_POST["Categorias"];
  17.     $Rx115registrado = $_POST["Rx115"];
  18.     $Rx115huilaregistrado = $_POST["Rx115 Huila"];
  19.     $Aireregistrado = $_POST["200 Aire"];
  20.     $Novatos200registrado = $_POST["200 Novatos"];
  21.  
  22. $conn->query("INSERT INTO registro (Nombre,Apellido,Cedula,Numerodepiloto,Categorias) values ('$Nombreregistrado', '$Apellidoregistrado' ,'$Cedularegistrada', '$Numerodepilotoregistrado')");
  23. $conn->query("INSERT INTO registro (Categorias) values ('$Rx115registrado', '$Rx115huilaregistrado', '$Aireregistrado', '$Novatos200registrado')");
  24.  
  25.  if (isset($_POST["Nombre"]) && isset($_POST["Apellido"]) && isset($_POST["Cedula"]) && isset($_POST["Numerodepiloto"]) && isset($_POST["Categorias"])){
  26.  }
  27.  else
  28.  {
  29.      echo"Debes de llenar todos los campos.";
  30.  }
  31.  
  32. ?>