Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created March 13, 2018 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/5c6c96031b2871fa28621752394928fa to your computer and use it in GitHub Desktop.
Save parzibyte/5c6c96031b2871fa28621752394928fa to your computer and use it in GitHub Desktop.
<?php
#Salir si alguno de los datos no está presente
if(
!isset($_POST["codigo"]) ||
!isset($_POST["descripcion"]) ||
!isset($_POST["precioCompra"]) ||
!isset($_POST["precioVenta"]) ||
!isset($_POST["existencia"]) ||
!isset($_POST["id"])
) exit();
#Si todo va bien, se ejecuta esta parte del código...
include_once "base_de_datos.php";
$id = $_POST["id"];
$codigo = $_POST["codigo"];
$descripcion = $_POST["descripcion"];
$precioCompra = $_POST["precioCompra"];
$precioVenta = $_POST["precioVenta"];
$existencia = $_POST["existencia"];
$sentencia = $base_de_datos->prepare("UPDATE productos SET codigo = ?, descripcion = ?, precioCompra = ?, precioVenta = ?, existencia = ? WHERE id = ?;");
$resultado = $sentencia->execute([$codigo, $descripcion, $precioCompra, $precioVenta, $existencia, $id]);
if($resultado === TRUE){
header("Location: ./listar.php");
exit;
}
else echo "Algo salió mal. Por favor verifica que la tabla exista, así como el ID del producto";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment