Created
October 14, 2019 21:42
-
-
Save parzibyte/5d3df5a6c943ce08080e4ea1da5529f9 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 | |
#If one of these are not present, exit | |
if ( | |
!isset($_POST["first_name"]) || | |
!isset($_POST["last_name"]) || | |
!isset($_POST["gender"]) || | |
!isset($_POST["id"]) | |
) { | |
exit(); | |
} | |
#If everything is OK, this code is executed | |
include_once "database.php"; | |
$id = $_POST["id"]; | |
$first_name = $_POST["first_name"]; | |
$last_name = $_POST["last_name"]; | |
$gender = $_POST["gender"]; | |
$statement = $database->prepare("UPDATE person SET first_name = ?, last_name = ?, gender = ? WHERE id = ?;"); | |
$result = $statement->execute([$first_name, $last_name, $gender, $id]); # Pass data in the same order as placeholders | |
if ($result === true) { | |
echo "Saved"; | |
} else { | |
echo "Something went wrong"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment