是否可以使用会话变量,然后直接取消设置?
例:
//====
//Process Form
if ($_POST['Submit']) {
$update = $userSettings->update($_POST);
//If there are form errors
if (!$update) {
//Load the errors into an array
$errors = $update[1];
} else {
//Set the session
$_SESSION['showUpdated'] = true;
//Redirect to this page
header("Location: http://www.mysite.com/settings");
}
}
//==================
if ($_SESSION['showUpdated']) {
echo "Settings Updated";
unset($_SESSION['showUpdated'];
}
所以在提交表单后,如果没有错误:
>设置一个会话来表示提交表单是可以的
>重新加载页面(以防止重新提交POST数据)
>如果设置了’showUpdated’会话变量,则显示“已更新”消息
>取消设置会话变量(所以我们看不到下一次重新加载的消息)
目前的问题是,如果你直接取消设置会话变量;就像在“if exists”部分之前取消设置一样.
任何解决方案?这甚至是最好的办法吗?
非常感谢!