This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php include_once "encabezado.php" ?> | |
<?php | |
#Salir si alguno de los datos no está presente | |
if(!isset($_POST["codigo"]) || !isset($_POST["descripcion"]) || !isset($_POST["precioVenta"]) || !isset($_POST["precioCompra"]) || !isset($_POST["existencia"])) exit(); | |
#Si todo va bien, se ejecuta esta parte del código... | |
include_once "base_de_datos.php"; | |
$codigo = $_POST["codigo"]; | |
$descripcion = $_POST["descripcion"]; | |
$precioVenta = $_POST["precioVenta"]; | |
$precioCompra = $_POST["precioCompra"]; | |
$existencia = $_POST["existencia"]; | |
$sentencia = $base_de_datos->prepare("INSERT INTO productos(codigo, descripcion, precioVenta, precioCompra, existencia) VALUES (?, ?, ?, ?, ?);"); | |
$resultado = $sentencia->execute([$codigo, $descripcion, $precioVenta, $precioCompra, $existencia]); | |
if($resultado === TRUE){ | |
header("Location: ./listar.php"); | |
exit; | |
} | |
else echo "Algo salió mal. Por favor verifica que la tabla exista"; | |
?> | |
<?php include_once "pie.php" ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment