Authentication (problem with headers)

From: Date: Wed, 18 Oct 2000 10:39:11 +0000
Subject: Authentication (problem with headers)
Groups: php.general 
Request: Send a blank email to php-general+get-20716@lists.php.net to get a copy of this message
I have been try to get the HTTP Authentication working but am having troubles first off i'm working on a linux server with Apachie web server when i create this php script and upload it to the web server. <?php if(!isset($PHP_AUTH_USER)) { Header("WWW-Authenticate: Basic realm=\"My Realm\""); Header("HTTP/1.0 401 Unauthorized"); echo "Text to send if user hits Cancel button\n"; exit; } else { echo "Hello $PHP_AUTH_USER.<P>"; echo "You entered $PHP_AUTH_PW as your password.<P>"; } ?> When i try to access this script with netscape i get this error in the browser Internal Server Error malformed header from script. Bad header=HTTP/1.0 401 Unauthorized It like the line "Header("HTTP/1.0 401 Unauthorized");" is not working and won't call up the user entry box. What i want to know is how to bring up this box and get the header comand to work. I have got the information on this from http://www.php.net/manual/html/features.http-auth.html if you want to take a look and the area in which the php program is at is http://www.prepress-studio.net/temp/auth01.php I will be greatful for any help i can get!

« previous php.general (#20716) next »