Hello!
I'm trying to do a login system that uses a text file for storing passwords.
Now I have the code reading the text file and checking the password - this works.
The page I want password protected is the admin page. Now I've included the password.php (login code) in the admin page using php include once.
Trouble is - the page kept loading the content in its entirety without checking to see if the user has entered in the correct password. So to stop this I included an 'exit' in the password.php that stopped the rest of the page loading.
Now what I need to know is, once the user has entered in the correct password - how do I get the admin page to load without the include again? Or perhaps I can use the if statement in the code to read the rest of the page - if so what would be the command? I've had a quick look at the manual and couldnt find anything...
Here is my code...
<?php
// if POST
// get contents of a file into a string
$filename = "pass.txt";
$file = fopen($filename, "r");
$filesize = filesize($filename);
$text = fread( $file, $filesize);
fclose($file);
if (isset($POST['Password']))
{
if($POST['Password'] == "$text")
{
$url = "admin.php"; // target of the redirect
$delay = "3"; // 3 second delay
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
} else {
echo "Nope not correct";
}
}
// display form:
else {
?>
<form action="<?php htmlentities($_SERVER['PHP_SELF'], ENT_QUOTES); ?>" method="POST">
Enter your password: <input type="password" name="Password" />
<input type="submit" />
<?php } ?>
<?php
exit;
?>
And in advance as I seem to be using this board a lot today - thank u V.V. much.