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!";
}
}

?>
PeejAvery at 2007-11-10 3:57:41 >
# 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?
vietboy505 at 2007-11-10 3:58:46 >
# 3 Re: PHP: user Authentication prompt
Remember that both are case-sensative. You can change this by changing the cases and comparing.
PeejAvery at 2007-11-10 3:59:45 >
# 4 Re: PHP: user Authentication prompt
I never got the dialog popup though.
vietboy505 at 2007-11-10 4:00:47 >
# 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.
PeejAvery at 2007-11-10 4:01:46 >
# 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.
vietboy505 at 2007-11-10 4:02:45 >
# 7 Re: PHP: user Authentication prompt
Sounds as though your IIS is not retaining server variables. You need to check the configuration of PHP.
PeejAvery at 2007-11-10 4:03:50 >
# 8 Re: PHP: user Authentication prompt
what do I need to change in php.ini?
vietboy505 at 2007-11-10 4:04:42 >
# 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.
PeejAvery at 2007-11-10 4:05:44 >