Here's the snippet that is breaking:
##################

if (!isset($PHP_AUTH_USER)) {
//if empty, send header causing a dialog box to appear
header('WWW-Authenticate: Basic realm="My Private Stuff" ');
header('HTTP/1.0 401 Unauthorized');
echo "Authorization Required.";
exit;
}
########################

########################
Here is the apache error log:
[Wed Jan 17 22:09:50 2001] [error] [client 208.37.96.157] malformed header from script. Bad header=HTTP/1.0 401 Unauthorized: d:/apache/modules/php4/php.exe
########################

I'm trying to get http authentication to work on my Windows ME PHP 4.04 running on apache 1.3.14
I did not set up any configuration in the httpd.conf file for directorys, but I'm going the route of a DB check against the password.

Anyone know of some documentation on this?

    Nate Yaconis wrote:

    Anyone know of some documentation on this?

    Yes, this forum. A quick search would have given you the info. For CGI version of PHP, you have to do this :

    Header("Status: 401 Unauthorized);

      a month later

      I tried to do this but it didn't help,
      I have a script that searches for some
      session variables, and if they exists and are
      correct then the page can be displayed,
      otherwise HTTP/1.0 401 Unauthorized, so I
      tried Status: 401 Unauthorized, and it just displays the page without taking the user to
      the 401 Unauthorized page??

      Any help would be much appriciated!

      Fotis

        a year later
        3 months later

        $PHP_AUTH_USER is only available if PHP is installed as a module (not as CGI). See the tutorial at zend.com:

        "The $PHP_AUTH_USER, $PHP_AUTH_PW and $PHP_AUTH_TYPE global variables are only available when PHP is installed as a module. If you're using the CGI version of PHP, you will be limited to Web server-based authentication or other custom types of authentication (such as using HTML forms) to match passwords in a database."

        http://www.zend.com/zend/tut/authentication.php

          Write a Reply...