Mira mi codigo:
Código PHP:
Ver original<?php
$conta = 'SELECT MAX(num_ingreso) AS num_ingreso FROM registro_ingreso';
$bus = $conexion->query($conta);
if ($bus->num_rows > 0){
$fila = $bus->fetch_array();
$n = 1 + $fila["num_ingreso"];
}
if(isset($_POST['registro'])){ if ($result = $conexion->query("INSERT INTO registro_ingreso (num_ingreso ,fecha_ingreso ,nombre, herramienta_ingresada, imagen ,empresa, salida_herramienta ,herramienta_retirada)
VALUES ('$n','{$_POST['fecha']}','{$_POST['nombre']}','{$_POST['ingreso']}','{$_POST['fotos']}','{$_POST['empresa']}','{$_POST['salida']}','{$_POST['retiro']}')"))
{
echo'<script>
alert("Registro Exitoso");
window.location.href="../index.php";
</script>';
}else{
echo'<script>
alert("Registro No Guardado");
window.location.href="formato.php";
</script>';
}
}
?>
Código HTML:
Ver original<form name="formulario" id="formulario" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<div align="center"><table id="tabla" width="97%" border="0"><br> <td width="160" style="border: 2px solid #016495;"><center><font color="white" size="3"/><b>N° Ingreso
</b></td> <td width="100" style="border: 2px solid #016495;"><center><font color="white" size="3"/><b>Fecha Ingreso
</b></td> <td width="160" style="border: 2px solid #016495;"><center><font color="white" size="3"/><b>Nombre
</b></td> <td width="160" style="border: 2px solid #016495;"><center><font color="white" size="3"/><b>Herramienta Ingresada
</b></td> <td width="160" style="border: 2px solid #016495;"><center><font color="white" size="3"/><b>Empresa
</b></td> <td width="150" style="border: 2px solid #016495;"><center><font color="white" size="3"/><b>Fecha Salida de Herramientas
</b></td> <td width="150" style="border: 2px solid #016495;"><center><font color="white" size="3"/><b>Herramienta Retirada
</b></td> <td><center><input type="text" size="3" value="<?php echo $n;?>" style="border:none; text-align:center; background-color:#ffffff" readonly/>
</center></td> <td><center><input type="date" name="fecha" style="border:none; background-color:#ffffff; text-align:center" required/></td> <td><textarea cols="22" rows="3" maxlength="30" style="border:none; background-color:#ffffff" name="nombre" required></textarea></td> <td><textarea cols="22" rows="3" maxlength="30" style="border:none; background-color:#ffffff" name="ingreso" required></textarea></td> <td><textarea cols="22" rows="3" maxlength="30" style="border:none; background-color:#ffffff" name="empresa" required></textarea></td> <td><input type="date" name="salida" size="16" style="border:none; background-color:#ffffff; text-align:center" required/></td> <td><textarea cols="22" rows="3" maxlength="30" style="border:none; background-color:#ffffff" name="retiro" required></textarea></td> <div align="center"><table id="archivos" width="97%" border="0"> <td width="15%"><font color="white" size="3"/><b>Adjuntar imagen:
</b></td> <td bgcolor="#ffffff"><input type="file" name="fotos" style="background-color:#ffffff" required/><td>