Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/11/2015, 18:42
valalmeida
 
Fecha de Ingreso: noviembre-2015
Ubicación: chile
Mensajes: 5
Antigüedad: 8 años, 6 meses
Puntos: 0
envio de datos por formulario POST

al enviar el formulario con un <select><option> me toma el nombre del cliente no el id ocurre lo mismo con el idAuto
Me podrían explicar por que hace esto :/

<?php
session_start();
include 'CapaDatos/coneccion.php';
if(!isset($_SESSION['admin']) || $_SESSION['admin'] > 0){
header('location:error.php');
}
$con =conectar();

if(isset($_POST['comprar'])){
/*
$auto=mysqli_query($con,"select * from auto");
while($fila=mysqli_fetch_array($auto)){
print_r($fila['idAuto']);
}*/
//$_POST['idAuto']=4;
$query2=mysqli_query($con,"insert into boleta (fecha,idCliente,idAuto, estado)values ('".$_POST['fecha']."','".$_POST['cliente']."','".$_POST['marca']."','".$_POST['estado']."')");

}

?>


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
<link href="estilo.css" rel="stylesheet" type="text/css">
</head>

<body>
<h1 id="titulos">Bienvenido usuario: <?php echo $_SESSION['nick'];?></h1> <a href="logout.php"> Cerrar Sesion</a>


<form action="boleta.php" method="POST" name="generarboleta">
<table width="40%" border="1" align="center" cellpadding="1" cellspacing="1">

<tr>
<td>Ingrese fecha:</td>
<td><input name="fecha" type="date" ></td>
</tr>
<td>Ingrese Estado</td>
<td ><select name="estado">
<option values="nuevo">nuevo</option>
<option values="usado">usado</option>
</select></td>
</tr>

<tr>
<td>Seleccione Vehiculo:</td>
<td><select name="marca">
<?php

$auto=mysqli_query($con,"select * from auto");
while($fila=mysqli_fetch_array($auto)){?>
<option values="<?= $fila['idAuto']?>"><?php echo $fila['marca']?>,<?php echo $fila['modelo']?>,<?php echo $fila['color']?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td>Ingrese Rut Cliente:</td>
<td>
<select name="cliente">

<?php
$cliente =mysqli_query($con,"select * from cliente");
//while ($cli = mysqli_fetch_array($cliente)){<?php }
foreach($cliente as $cli):
?>

<option values="<?php echo $cli['idCliente']?>"><?php echo $cli['nombre']?></option>
<?php endforeach;?>
</select>

</td>
</tr>
<tr>
<td></td>
<td><input name="comprar" type="submit" value="comprar" ></td>
<input type="number" max="10" min="3" >
</tr>
</table>


</form>

</body>
</html>