php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: wex at media dot mit dot edu
New email:
PHP Version: OS:

 

 [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

<?php
if ((!isset($PHP_AUTH_USER)) || (!isset($PHP_AUTH_PW))) {
    header("WWW-Authenticate: Basic realm=\"My Realm\"");
    header("HTTP/1.0 401");
    echo "Authorization Required.";
    exit; 
} 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-10 06:49 UTC] sniper@php.net
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.

--Jani

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 02:01:38 2025 UTC