我创建了一个表单来更新数据,经过一些困难我成功了,但现在我需要执行必要的检查并输入错误消息或成功。我试过这个,但没有任何反应:
//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;
}
如何通过添加字段等必要的检查来改进它,并插入错误消息并成功?感谢