以下代码通过用户名检查,但在密码检查失败。
如您所见,哈希值被回显,但由于某种原因,它们输出e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
,即sha256sum
of /dev/null
。由于密码似乎根本没有回显,我只能假设它无法获取 POST,但为什么呢?
登录
<form action="dologin" method="post">
Username: <input type="text" name="username">
Password: <input type="password" name="password">
<input type="submit">
</form>
多洛金
if ( $_POST[username] == $actualusername ) {
// Hash the password
$hashedpassword = hash('sha256', $_POST[password]);
echo $_POST[password];
echo $hashedpassword;
if ( $hashedpassword == $actualpassword ) {
echo '<h2>Logged in</h2>';
} else {
echo '<h2>Incorrect password</h2>';
echo $hashedpassword;
}
} else {
echo '<h2>Incorrect username</h2>';
}