这是一个单用户登录验证php文件。当登录php提交散列密码和用户名时,这个verify.php检查login.php发布的数据,如果它们是正确的,它将重定向到相关的index.php。这很好用,现在如何使用另一个php命令更新密码?使用表单提交命令。
var rndTile = Math.floor((Math.random() * 40) + 1);
var base = 2 / 2;
var colChoices = ["#81A594","#79BEDB","#6B78B4", "#593E1A", "#99CCCC"];
var fadeTime = Math.floor((Math.random * 6000));
答案 0 :(得分:0)
好的,这是让你入门的事情:
这是你的verify.php:
<?php
if ($_POST['user'] == "ppks82" &&
md5($_POST['pass']) == file_get_contents("password.txt") {
session_start();
$_SESSION['user'] = $_POST['user'];
header('Location: index.php');
exit;
} else {
header('Location: login.php');
}
?>
现在创建一个名为changepw.php的文件:
<?php
session_start();
if (empty($_POST['user'])) {
header('Location: login.php');
exit;
}
if (isset($_POST['password'])) {
file_put_contents('password.txt', md5($_POST['password']));
echo 'password changed.';
exit;
}
?>
<form method="post" action="">
New password: <input type="password" name="password">
<input type="submit">
</form>
现在创建另一个名为password.txt的文件并放入9f5tf71ca91p693a36c403d75a377864
。
如果可能,将password.txt移到文档根目录之外,并在php中使用../password.txt
访问它。