I have a form in a php attempt with the date field
<form action="../control/registrar_factura.php" method="POST">
<h3>Ingrese los datos</h3>
<!-------Tabla DATOS----------------------------------->
Datos facturacion
<label id="etiqueta" for="id_factura">Numero de Factura:</label>
<?php $query = $conexion->query("SELECT * FROM facturas");
while ($valores = mysqli_fetch_array($query)) {
$valor=$valores['id_factura'];
$actual = $valor+1;?>
<input type="text" id="id_factura" name="id_factura" class="cajas" value="<?php echo $actual;}?>" disabled>
<label id="etiqueta" for="id_usuario">Usuario Factura:</label>
<input type="text" class="cajas" value="<?php echo $_SESSION['nombreusuario'] . " " . $_SESSION['apellidousuario']?>"disabled>
<input type="text" value="<?php echo $_SESSION['username']?>" name="id_usuario"/>
<label id="etiqueta" for="fecha">Fecha de Facturacion:</label>
<?php $fecha = date("Y-m-d H:i:s", time()); echo '<input type="text" id="fecha" name="fecha" class="cajas" value="'.$fecha.'" disabled>';?>
But when I press the button, the fields do not arrive where I need it and I get an index error, this is the page that processes the data
<?php
include '../control/conexion.php';
$result = $conexion->query("SELECT * FROM facturas");
while($row=mysqli_fetch_array($result)) { foreach ($row as $key => $val) { echo "<td>" .$key. ': ' . $val . "</td>"; } echo ''; }
$id = $_POST['id_factura'];
$fecha = $_POST['fecha'];
echo $id;
echo $fecha;
$query = "INSERT INTO facturas (fecha, id_usuario, id_cliente, id_serv_1, id_serv_2, id_serv_3, id_producto_1, cant_facturada_1, valor_total_1, id_producto_2, cant_facturada_2, valor_total_2, id_producto_3, cant_facturada_3, valor_total_3, id_producto_4, cant_facturada_4, valor_total_4, id_producto_5, cant_facturada_5, valor_total_5, total_factura) VALUES ('$_POST[fecha]', '$_POST[id_usuario]', '$_POST[id_cliente]', '$_POST[id_servicio]', '$_POST[id_servicio1]', '$_POST[id_servicio2]', '$_POST[id_prod]', '$_POST[cant_factu]', '$_POST[valor_total]', '$_POST[id_prod1]', '$_POST[cant_facturada1]', '$_POST[valor_total1]', '$_POST[id_prod2]', '$_POST[cant_facturada2]', '$_POST[valor_total2]', '$_POST[id_prod3]', '$_POST[cant_facturada3]', '$_POST[valor_total3]', '$_POST[id_prod4]', '$_POST[cant_facturada4]', '$_POST[valor_total4]', '$_POST[total_factura]')";
if ($conexion->query($query) === TRUE) {
echo "<script> var r = confirm('Factura: ".$_POST['id_factura']." Registrada Exitosamente!....registrar nueva factura?');
if (r == true) {
window.location.href='../vista/generar_factura.php';
} else {
window.location.href='../vista/panel_control.php';
}
</script>";
} else {
echo $conexion->error;
echo "<script>alert('Error al registrar la factura.'); window.location.href='../vista/panel_control.php';</script>";
}
mysqli_close($conexion);
?>
I have no idea what I'm doing wrong Thanks