Login Redirect
Posted: Sun Mar 30, 2003 6:34 pm
Hello,
I have a login script that when someone logs in it directs them to there folder.. I want a script to add into the index.php file of the users folder so that if they just type in the url with the folder name it ownt just bypass the login script.. so I need it to force the user to log in.. heres the log in code I use..
login.php
Thanx for your help..
I have a login script that when someone logs in it directs them to there folder.. I want a script to add into the index.php file of the users folder so that if they just type in the url with the folder name it ownt just bypass the login script.. so I need it to force the user to log in.. heres the log in code I use..
login.php
Code: Select all
<?php
# I suggest using && instead of AND. Different interpretations/precedence and all that
if(($PHP_AUTH_USER == "usr1") && ($PHP_AUTH_PW == "test"))
{
header("Location: /usr1/");
}
# you forgot to use elseif for the second statement.
elseif(($PHP_AUTH_USER == "us2") && ($PHP_AUTH_PW == "test"))
{
header("Location: /usr2/");
}
else
{
header("WWW-Authenticate: Basic realm="Subdomain"");
header("HTTP/1.0 401 Unauthorized");
print("This page is PROTECTED by HTTP Authentication.<br>");
print("DO NOT TRY TO ACCESS THIS SITE IF YOU ARE NOT AUTHORIZED!");
}
?>