Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created March 13, 2018 17:25
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/a9eaa09fc9dae3e68cc04a81a5d2871a to your computer and use it in GitHub Desktop.
Save parzibyte/a9eaa09fc9dae3e68cc04a81a5d2871a to your computer and use it in GitHub Desktop.
<?php
if(!isset($_GET["id"])) exit();
$id = $_GET["id"];
include_once "base_de_datos.php";
$sentencia = $base_de_datos->prepare("SELECT * FROM productos WHERE id = ?;");
$sentencia->execute([$id]);
$producto = $sentencia->fetch(PDO::FETCH_OBJ);
if($producto === FALSE){
echo "¡No existe algún producto con ese ID!";
exit();
}
?>
<?php include_once "encabezado.php" ?>
<div class="col-xs-12">
<h1>Editar producto con el ID <?php echo $producto->id; ?></h1>
<form method="post" action="guardarDatosEditados.php">
<input type="hidden" name="id" value="<?php echo $producto->id; ?>">
<label for="codigo">Código de barras:</label>
<input value="<?php echo $producto->codigo ?>" class="form-control" name="codigo" required type="text" id="codigo" placeholder="Escribe el código">
<label for="descripcion">Descripción:</label>
<textarea required id="descripcion" name="descripcion" cols="30" rows="5" class="form-control"><?php echo $producto->descripcion ?></textarea>
<label for="precioVenta">Precio de venta:</label>
<input value="<?php echo $producto->precioVenta ?>" class="form-control" name="precioVenta" required type="number" id="precioVenta" placeholder="Precio de venta">
<label for="precioCompra">Precio de compra:</label>
<input value="<?php echo $producto->precioCompra ?>" class="form-control" name="precioCompra" required type="number" id="precioCompra" placeholder="Precio de compra">
<label for="existencia">Existencia:</label>
<input value="<?php echo $producto->existencia ?>" class="form-control" name="existencia" required type="number" id="existencia" placeholder="Cantidad o existencia">
<br><br><input class="btn btn-info" type="submit" value="Guardar">
<a class="btn btn-warning" href="./listar.php">Cancelar</a>
</form>
</div>
<?php include_once "pie.php" ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment