我正在尝试为index.php添加密码保护表单,以便人们无法在没有密码的情况下进入网站。我不想将htaccess用于htaccess的视觉问题。
<?php
if( !empty ($_POST['password'] ) ) {
$password = "1234";
$pw = md5($_POST['password']);
$valid_password = md5($password);
if( $pw != $valid_password ) {
echo "Error! You do not have access to this websitesite.";
} else {
require(dirname(__FILE__).'/config/config.inc.php');
Dispatcher::getInstance()->dispatch();
}
}else{
echo '
<h2> Please Type Your Password to Enter to the website. </h2>
<form name="monkeybusiness" method="post" action="\index.php">
<input type="password" id="password" name="password />
<input type="submit" id="submit" value="Enter" />
</form>';
}
但输入密码时我会收到以下错误;
Forbidden
You do not have permission to access this document.
有谁知道这个错误的原因是什么? 感谢。