-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidar_reg_implemento.php
More file actions
35 lines (33 loc) · 1.7 KB
/
validar_reg_implemento.php
File metadata and controls
35 lines (33 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
// Verificar si se ha enviado el formulario
//Validacion y registro de Implemento
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Recoger datos del formulario
$nombre= $_POST["nombre_implemento"];
$stock= $_POST["stock_implemento"];
$stock_min= $_POST["stock_minimo"];
$foto= $_POST["foto"];
$ubicacion= $_POST["ubicacion"];
$und_medida= $_POST["und_medida"];
$ficha_tecnica= $_POST["ficha_tecnica"];
$guia= $_POST["guia_uso_lab"];
// Conectar a la base de datos
include_once("db.php");
$conectar = conn(); //conexion a la base de datos
$sql = "INSERT INTO implemento (nombre_implemento,stock_implemento,stock_minimo,ficha_tecnica,foto,guia_uso_lab,ubicacion_fk,und_medida_fk) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
// Preparar la sentencia SQL para insertar una nueva reserva en la base de datos
$stmt = $conectar->prepare($sql);
//bind
$stmt->bind_param("siissssi",$nombre,$stock,$stock_min,$ficha_tecnica,$foto,$guia,$ubicacion,$und_medida);
// Ejecutar la sentencia SQL
if ($stmt->execute()) {
echo '<div class="alert alert-success" role="alert">Implemento registrado correctamente</div>';
header("Location: registro_insumo.php");
} else {
echo '<div class="alert alert-danger" role="alert"> Error al registrar implemento: </div>' . $stmt->error;
header("Location: registro_insumo.php");
}
$stmt->close();
$conectar->close();
}
?>