| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2001-06-10 06:49 UTC] sniper@php.net
  | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 14:00:01 2025 UTC | 
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.