Created
February 12, 2018 23:40
-
-
Save parzibyte/734afac58d1f166a981d29b7a5b7a68f to your computer and use it in GitHub Desktop.
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 | |
#Salir si alguno de los datos no está presente | |
if( | |
!isset($_POST["nombre"]) || | |
!isset($_POST["apellidos"]) || | |
!isset($_POST["sexo"]) || | |
!isset($_POST["id"]) | |
) exit(); | |
#Si todo va bien, se ejecuta esta parte del código... | |
include_once "base_de_datos.php"; | |
$id = $_POST["id"]; | |
$nombre = $_POST["nombre"]; | |
$apellidos = $_POST["apellidos"]; | |
$sexo = $_POST["sexo"]; | |
$sentencia = $base_de_datos->prepare("UPDATE personas SET nombre = ?, apellidos = ?, sexo = ? WHERE id = ?;"); | |
$resultado = $sentencia->execute([$nombre, $apellidos, $sexo, $id]); # Pasar en el mismo orden de los ? | |
if($resultado === TRUE) echo "Cambios guardados"; | |
else echo "Algo salió mal. Por favor verifica que la tabla exista, así como el ID del usuario"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment