Re: HTTP Authentication

From: Date: Wed, 07 Feb 2001 17:06:10 +0000
Subject: Re: HTTP Authentication
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-38568@lists.php.net to get a copy of this message
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"; } } ?> ----- Original Message ----- From: "Nick Kostirya" <nick@han.kherson.ua> To: <php-general@lists.php.net> Sent: Wednesday, February 07, 2001 10:27 AM Subject: [PHP] HTTP Authentication > Hi, all. > HTTP Authentication in PHP 4 - Apache don't work!!! > Help me. > Best. > __________________________________________________ > <?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>"; > } > ?> > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#38568) next »