PHP: user Authentication prompt
I am running IIS, mySQL & PHP installed.
I want to prompt a dialog to ask user to enter in their username & secret text without using JavaScript.
php://stdin
Then I will select the username to match the secret text & in the database.
I look at PHP Authentication but I keep get not authorize.
Can any one help me started on the dialog popup?
[387 byte] By [
vietboy505] at [2007-11-19 19:52:04]

# 1 Re: PHP: user Authentication prompt
PHP.net has many examples. You must use the server variables PHP_AUTH_USER and PHP_AUTH_PW. Below is an example.
<?php
$user = "USER HERE";
$pass = "PASSWORD HERE";
if (!isset($_SERVER['PHP_AUTH_USER'])){
header('WWW-Authenticate: Basic realm="Administration"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authentication Cancelled.';
exit;
}
else{
if($_SERVER['PHP_AUTH_USER']=="$user" and $_SERVER['PHP_AUTH_PW']=="$pass"){
echo "Login Passed!";
}
else{
echo "Login Failed!";
}
}
?>
# 2 Re: PHP: user Authentication prompt
I got error:
You are not authorized to view this page
You do not have permission to view this directory or page using the credentials you supplied.
No windows popup to confirm user/pass.
Do I need set PHP_AUTH_USER some where?
# 5 Re: PHP: user Authentication prompt
Do you have this at the very top of the PHP page. This code must go before all other code because it has headers.
# 6 Re: PHP: user Authentication prompt
I tested the same code in my web server on a register domain and it has the popup dialog box for authenciation.
But in my other local intranet running on IIS with PHP, no dialog popup but just have You are not authorized to view this page
You do not have permission to view this directory or page using the credentials you supplied.
# 9 Re: PHP: user Authentication prompt
Well, before we get that far, there is something I forgot. To make HTTP authentication work with PHP on IIS you have to have ISAPI ( http://www.visualwin.com/PHP-ISAPI/). Check it out make sure that you have this installed and configured.