vendredi 17 avril 2015

Error message and check the fields

I created a form to update the data, after some difficulty I succeeded, but now I need to perform the necessary checks and enter the error messages or success. I tried this, but nothing happens:



//submit post
if (isset($_POST['email'], $_POST['location'], $_SESSION['username'])) {

//query update
$stmt = $db->prepare("UPDATE members SET email = ?, location = ? WHERE username = ?");
$status = $stmt->execute([$_POST['email'], $_POST['location'], $_SESSION['username']]);
if ($status) {
echo 'It worked!';
} else {
echo 'It failed!';
}

//redirect to index page
header('Location: account.php');
exit;

}


How can I improve it by adding the necessary checks of the fields etc., and insert the error messages and successful? thanks


Aucun commentaire:

Enregistrer un commentaire