RE: [PHP] User Authentication

From: Date: Tue, 27 Feb 2001 13:15:15 +0000
Subject: RE: [PHP] User Authentication
Groups: php.general 
Request: Send a blank email to php-general+get-41827@lists.php.net to get a copy of this message
Try this, it works for me. Mike if(!isset($PHP_AUTH_USER)) { Header("WWW-Authenticate: Basic realm=\"User Database\""); Header("HTTP/1.0 401 Unauthorized"); echo "<H1>ERROR</H1>You must enter a correct username and password in order to proceed\n"; exit; } else { if ($PHP_AUTH_USER=="admin" && $PHP_AUTH_PW=="love2change"){ print "You are successfully authenticated"; } else { Header("WWW-Authenticate: Basic realm=\"User Database\""); Header("HTTP/1.0 401 Unauthorized"); echo "You did not supply proper credentials and are therefore denied login\n"; exit; } } ?> -----Original Message----- From: Amer Alhabsi [mailto:alhabsi_NOSPAM@squ.edu.om] Sent: Tuesday, February 27, 2001 1:42 AM To: php-general@lists.php.net Subject: [PHP] User Authentication Hi, I'm trying to use an authentication method I found in a tutorial in the net. The server prompts for username/password. But if I enter the hard coded values (or any other values) the server rejects them with a message authorization failed. I use PHP 4 as a module on IIS Thanks very much for any help, here is the program I got from the tutorial. <?php if ( ( !isset( $PHP_AUTH_USER )) || (!isset($PHP_AUTH_PW)) || ( $PHP_AUTH_USER != 'user' ) || ( $PHP_AUTH_PW != 'open' ) ) header( 'WWW-Authenticate: Basic realm="Private"' ); header( 'HTTP/1.0 401 Unauthorized' ); echo 'Authorization Required.'; exit; } else echo 'Success!'; } ?> -- 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 (#41827) next »