|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11375 Header function not performing as documented
Submitted: 2001-06-09 02:55 UTC Modified: 2001-06-10 06:49 UTC
From: wex at media dot mit dot edu Assigned:
Status: Closed Package: HTTP related
PHP Version: 4.0.5 OS: W2K
Private report: No CVE-ID: None
 [2001-06-09 02:55 UTC] wex at media dot mit dot edu
I'm having trouble getting Header to work with Apache 1.3.19 on W2K.

If I say

if ((!isset($PHP_AUTH_USER)) || (!isset($PHP_AUTH_PW))) {
    header("WWW-Authenticate: Basic realm=\"My Realm\"");
    header("HTTP/1.0 401");
    echo "Authorization Required.";
} else { 
    echo "You entered $PHP_AUTH_USER for a username.<BR>"; 
    echo "You entered $PHP_AUTH_PW for a password.<BR>"; 

Apache generates an error " malformed header from script. Bad header=HTTP/1.0 401:"

If I change the second Header call to be
header("status: 401 Unauthorized");
then Apache doesn't generate an error, and the login prompt appears.  HOWEVER, the script never hits the "else" case.  It always just reprompts for u/pw no matter what I put in.

Note that I'm using PHP as a module, not through CGI.
I downloaded the precompiled PHP and Apache binaries (released versions, not beta) from the Web sites, so compile options are standard.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-10 06:49 UTC]
You most likely are NOT using the module but indeed are using the CGI. I just tested this and it works just fine
for me with Apache 1.3.20 / PHP 4.0.5 on Win ME.

Please read the install.txt that comes with the package.
I did this myself first time now and I got it working
immediately by following the instructions.

You might have installed PHP as CGI sometime before.
I suggest you reinstall Apache / PHP.


PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Oct 31 11:01:24 2020 UTC