www authentication

From: Date: Mon, 01 Jul 2002 17:14:13 +0000
Subject: www authentication
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-11092@lists.php.net to get a copy of this message
hi, i am using www authentication and hoped you could help me, or perhaps forward this to someone who could. i am making a login script in php and although it works its only on the 3rd time i enter the username and password that it works the other 2 it just refreshes the username and password box. here is the code: <?php header("WWW-Authenticate: Basic realm=\"Client Lounge\""); header("HTTP/1.0 401 Unauthorized"); function LoginOK($user, $pass) { if (empty($user)||empty($pass)) { return false; } else { define ('HOST', 'localhost'); define ('USER', '******'); define ('PASS', '******'); define ('DB', '******'); mysql_connect (HOST, USER, PASS); mysql_select_db(DB); $result = mysql_query("SELECT COUNT(*) AS numfound FROM users WHERE user='$user' AND pass='$pass'"); $result_ar=mysql_fetch_array($result); if ($result_ar['numfound'] < 1) //********Login Failed********** { return false; } else {//********Login Information accepted********** return true; } } } if (! LoginOK($PHP_AUTH_USER, $PHP_AUTH_PW)) { header("WWW-Authenticate: Basic realm=\"Client Lounge\""); header("HTTP/1.0 401 Unauthorized"); echo "You are required to log in to access this protected resource."; exit; } ?> login worked

« previous php.mirrors (#11092) next »