我的应用程序是一个简单的登录页面。当它失败时,我打印一条错误消息。我的问题是,为什么当我重新加载页面时,邮件又被打印了?我该如何解决这个问题? 代码工作正常,我做了另一个php文件执行数据库检查&连接。为什么POST ['submit']在我重新加载时设置?
<?php
require_once("include/database.php");
if(isset($_POST['submit'])) {
connect_bookstore(); // custom function
$spassword = sha1($_POST['password']);
$username = $_POST['username'];
if (checkpassword($username,$spassword)) { //custom function
header('Location:insert.php');
exit;
} else {
$message = "Login failed!";
}
}
?>
在html正文中。
<?php
if (isset($message)) {
echo $message;
}
?>
[只能使用$ _POST信息一次](http://stackoverflow.com/questions/8171227/using-post-information-only-once) – Gian
你应该给你的哈希值加盐。 – SLaks