PHP Auth
Posted: Sat Mar 22, 2003 7:10 pm
Hello,
This is my problem. Im new to PHP and im still learning. In one of my subdomains I want to have a login script that when you type in http://subdomain.TLD.com a login windows pops up.. now I got that far.. but my problem is I want each username to go to a diff folder in the subdomain. so say theres two folders folder1 & folder2 if i enter in username= f1 pw= test it should load folder1 and same if i neter in user=f2 pw=test it should take me to folder2 heres the code im using to pop up the login window. I have this code in my index.php
Code:
<?
if(($PHP_AUTH_USER == "f1") AND ($PHP_AUTH_PW == "test"))
{
print("<HTML>\n");
print("<HEAD>\n");
print("<TITLE>Welcome to Members Area</TITLE>\n");
print("</HEAD>\n");
print("<BODY>\n");
print("You have logged in successfully!<BR>\n");
}
else
{
header("WWW-Authenticate: Basic realm=\"Subdomain\"");
header("HTTP/1.0 401 Unauthorized");
print("This page is PROTECTED by HTTP Authentication.<br>\n");
print("DO NOT TRY TO ACCESS THIS SITE IF YOU ARE NOT AUTHERIZED!");
}
?>
I know that I will need aonther if for the second user but I dont know where it should go.. thanx for your help
Stephen
This is my problem. Im new to PHP and im still learning. In one of my subdomains I want to have a login script that when you type in http://subdomain.TLD.com a login windows pops up.. now I got that far.. but my problem is I want each username to go to a diff folder in the subdomain. so say theres two folders folder1 & folder2 if i enter in username= f1 pw= test it should load folder1 and same if i neter in user=f2 pw=test it should take me to folder2 heres the code im using to pop up the login window. I have this code in my index.php
Code:
<?
if(($PHP_AUTH_USER == "f1") AND ($PHP_AUTH_PW == "test"))
{
print("<HTML>\n");
print("<HEAD>\n");
print("<TITLE>Welcome to Members Area</TITLE>\n");
print("</HEAD>\n");
print("<BODY>\n");
print("You have logged in successfully!<BR>\n");
}
else
{
header("WWW-Authenticate: Basic realm=\"Subdomain\"");
header("HTTP/1.0 401 Unauthorized");
print("This page is PROTECTED by HTTP Authentication.<br>\n");
print("DO NOT TRY TO ACCESS THIS SITE IF YOU ARE NOT AUTHERIZED!");
}
?>
I know that I will need aonther if for the second user but I dont know where it should go.. thanx for your help
Stephen