Re: HTTP Authentication - Message 2

From: Date: Thu, 08 Feb 2001 07:34:46 +0000
Subject: Re: HTTP Authentication - Message 2
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-38686@lists.php.net to get a copy of this message
Dear Shane, Thanks for response. But when I use PHP3 and Apache than all is good. And when I use PHP4 (!!!) and Apache than Apache don't understanding header ('HTTP/1.0 401 Unauthorized'), and Apache's "error.log" consist of "Bad header=HTTP/1.0 401 Unauthorized: d:/program files/php/php.exe". Do you know what is the matter? Thanks in advance. Nick. ----- Original Message ----- From: Shane McBride <php@riversidedesigns.net> To: Nick Kostirya <nick@han.kherson.ua>; <php-general@lists.php.net> Sent: Wednesday, February 07, 2001 7:06 PM Subject: Re: [PHP] HTTP Authentication > Nick, > > I'm not sure were you are getting the value of $PHP_AUTH_USER from, so you > might want to try this snippet. This causes a dialog box to open and ask for > a username/password. > > Also, in your code: you do not need to escape the quotes in the header. > > <? > // Check to see if $PHP_AUTH_USER already contains info > if (!isset($PHP_AUTH_USER)) { > // If empty, send header causing dialog box to appear > header('WWW-Authenticate: Basic realm="Whatever You want to say"'); > header('HTTP/1.0 401 Unauthorized'); > echo 'Authorization Required!'; > exit; > } else if (isset($PHP_AUTH_USER)) { > if (($PHP_AUTH_USER !="abc") || ($PHP_AUTH_PW !="123")) { > header('WWW-Authenticate: Basic realm="Whatever You want to say"'); > header('HTTP/1.0 401 Unauthorized'); > echo 'Authorization Required!'; > exit; > } else { > // Start echo statement > echo "hello"; > } > } > ?>

« previous php.general (#38686) next »