Forum Moderators: coopster
Files in the /folder will just #include a script to check the session is authenticated else redirect to the login page. The login page will set a session varaible by checking the password matches the one in the text file
Is this how it works in php? or is there a much easier way - Could someone give me start with the code.
Thanks
At the top of each page, you have something like:
session_register("auth");if (!$auth)
{
header("Location: login.php");exit();
}
and then the form processing part of login.php, assuming the password has been supplied in the form variable $password:
session_register("auth");if ($password)
{
$fp = fopen("/somewhere/out/of/wwwroot/password.txt","r");if (strtolower($password) == strtolower(trim(fgets($fp)))
{
$auth = TRUE;header("Location: secretpage.php");
exit();
}
else
{
echo("Authentication failed.");
}
}// login form
That's OTTOMH so apologies for syntactical errors; but it should give you a starting point.