I recently got a copy of that "PHP and MySQL Web
Development" book and found a script that lets you do
a simple authorization script with a login popup box
where you have to enter the username and password to
continue. The code in the book has it where it shows
text like "authorization successful" instead of
redirecting you to the next page (default.php in my
situation) so I was wondering what the command is I
have to enter at the end to have a successful login
take me to the default.php page. What I basically need
is the proper REDIRECT code under the "// visitor has
provided correct details" area.

Here is a sample of the source:


<?

// if we are using IIS, we need to set $PHP_AUTH_USER
and $PHP_AUTH_PW
if (substr($SERVER_SOFTWARE, 0, 9) == "Microsoft" &&
    !isset($PHP_AUTH_USER) &&
    !isset($PHP_AUTH_PW) &&
    substr($HTTP_AUTHORIZATION, 0, 6) == "Basic "
   ) 
{ 
  list($PHP_AUTH_USER, $PHP_AUTH_PW) = 
    explode(":",
base64_decode(substr($HTTP_AUTHORIZATION, 6))); 
} 

// Replace this if statement with a database query or
similar
if ($PHP_AUTH_USER != "user" || $PHP_AUTH_PW !=
"password")
{
  // visitor has not yet given details, or their 
  // name and password combination are not correct

  header('WWW-Authenticate: Basic realm="Site Admin"');
  if (substr($SERVER_SOFTWARE, 0, 9) == "Microsoft") 
    header("Status: 401 Unauthorized"); 
  else 
    header("HTTP/1.0 401 Unauthorized"); 

  echo "<h1>Invalid Login</h1>";
  echo "You have not supplied proper information to
access this page.";
} 
else 
{
  // visitor has provided correct details
header("Location: default.php");

}

?>




-- 

_______________________________________________
FREE Personalized E-mail at Mail.com 
http://www.mail.com/?sr=signup 

Talk More, Pay Less with Net2Phone Direct(R), up to 1500 minutes free! 
http://www.net2phone.com/cgi-bin/link.cgi?143 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to