speaker219
12-29-2005, 10:10 PM
I am using a very simple php login script. I need to know if there is a way to require someone to type in the password for another .php file.
For example if I had the script in login.php and I had another file called protected.php could I add a line at the top of the php page to require the users to type in the password to see the content in protected.php? I have heard of the php require function but do not know how to use it???
here is the code:
<?PHP
$pass = $_POST['pass'];
if ($pass == 'rightpassword') {
echo 'right!';
} elseif ($pass == '') {
echo '';
} else {
echo 'wrong';
}
?>
<HTML>
<h1><font color="red">AUTHORIZATION REQUIRED</font></h1>
<b><font color="red">Authorization is required past this point. You must enter the correct password to continue.</font></b>
<form action="/login/" method="post">
<input type="password" name="pass">
<input type="submit">
</form>
</HTML>
a live example can be found at : http://tst4php.6te.net/login/
thanks to anyone who can help!
For example if I had the script in login.php and I had another file called protected.php could I add a line at the top of the php page to require the users to type in the password to see the content in protected.php? I have heard of the php require function but do not know how to use it???
here is the code:
<?PHP
$pass = $_POST['pass'];
if ($pass == 'rightpassword') {
echo 'right!';
} elseif ($pass == '') {
echo '';
} else {
echo 'wrong';
}
?>
<HTML>
<h1><font color="red">AUTHORIZATION REQUIRED</font></h1>
<b><font color="red">Authorization is required past this point. You must enter the correct password to continue.</font></b>
<form action="/login/" method="post">
<input type="password" name="pass">
<input type="submit">
</form>
</HTML>
a live example can be found at : http://tst4php.6te.net/login/
thanks to anyone who can help!