I'm trying to add a password protection form to index.php so people cannot enter the website without a password. I don't want to use htaccess for visual problems of 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>';
}
but when enter the password I'm getting following error;
Forbidden
You do not have permission to access this document.
Does anybody know what is the reason of this error? Thanks.