A
Anonymous
Guest
help please.
i'm wanting to have a login page on a site that will depending on the login details send a user to a particular secure page e.g. user001 sent to page001.htm, user002 sent to page002.htm etc.
someone wrote this for me but it doesn't seem to work anywhere i've tried it (different servers etc). it asks for the password 3 times then sends user straight to the 'Access Denied!' page every time.
i'm completely new to php having come from a design background.
-------------------------------------------------
<?php
// If user isn't authenticated
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic Realm="please login"');
header('HTTP/1.0 401 Unathorized');
echo "<h1>Access Denied!</h1>\n";
exit;
} else {
switch($_SERVER['PHP_AUTH_USER']) {
case 'admin': // Is username is admin
if ($_SERVER['PHP_AUTH_PW'] == 'admin') {
header("Location: http://www.yahoo.com/");
exit;
} else {
echo "Auth failed!\n";
}
break;
case 'user':
if ($_SERVER['PHP_AUTH_PW'] == 'password') {
header("Location: http://www.google.com/");
exit;
} else {
echo "Auth failed!\n";
}
break;
case 'peter':
if ($_SERVER['PHP_AUTH_PW'] == 'thegreek') {
header("Location: http://www.bbc.co.uk/");
} else {
echo "Auth failed!\n";
}
break;
default:
break;
}
}
?>
-------------------------------------------------
hope someone can help
thanks
rex
i'm wanting to have a login page on a site that will depending on the login details send a user to a particular secure page e.g. user001 sent to page001.htm, user002 sent to page002.htm etc.
someone wrote this for me but it doesn't seem to work anywhere i've tried it (different servers etc). it asks for the password 3 times then sends user straight to the 'Access Denied!' page every time.
i'm completely new to php having come from a design background.
-------------------------------------------------
<?php
// If user isn't authenticated
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic Realm="please login"');
header('HTTP/1.0 401 Unathorized');
echo "<h1>Access Denied!</h1>\n";
exit;
} else {
switch($_SERVER['PHP_AUTH_USER']) {
case 'admin': // Is username is admin
if ($_SERVER['PHP_AUTH_PW'] == 'admin') {
header("Location: http://www.yahoo.com/");
exit;
} else {
echo "Auth failed!\n";
}
break;
case 'user':
if ($_SERVER['PHP_AUTH_PW'] == 'password') {
header("Location: http://www.google.com/");
exit;
} else {
echo "Auth failed!\n";
}
break;
case 'peter':
if ($_SERVER['PHP_AUTH_PW'] == 'thegreek') {
header("Location: http://www.bbc.co.uk/");
} else {
echo "Auth failed!\n";
}
break;
default:
break;
}
}
?>
-------------------------------------------------
hope someone can help
thanks
rex