Re: password protect WRM2

From: Date: Sun, 07 Jan 2001 20:57:54 +0000
Subject: Re: password protect WRM2
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-33119@lists.php.net to get a copy of this message
Hello David, (DS == "David Smith") webmaster@indywebdesign.com writes: DS> I am currently using the following code to password protect a file DS> but it uses only one login/pass. How would I change this code to DS> accept multiple logins by checking fields login/pass from a mysql DS> db? function Authenticate() { /* old code from an old class */ /* will need adjustments for your code */ reset($GLOBALS); $username = $GLOBALS['PHP_AUTH_USER']; $password = $GLOBALS['PHP_AUTH_PW']; $this->errorMsg = "<h1>Authorization Required</h1>\n"; $this->errorMsg .= 'In order to enter this section of '; $this->errorMsg .= 'the web site, you must provide valid '; $this->errorMsg .= 'credentials. If you think you may have '; $this->errorMsg .= 'made mistake, please reload this page '; $this->errorMsg .= "and try again.\n"; $this->errorMsg .= "<p>\n<hr>\n"; if(!isset($username) or !isset($password)) return false; $a_query = 'SELECT COUNT(username) AS total FROM '; $a_query .= "auth WHERE username = '$username' "; $a_query .= "AND password = password('$password')"; if(!$result = @mysql_query($a_query, $this->link)): $this->error_msg = 'Unable to validate login. '; $this->error_msg .= 'Reason: '; $this->error_msg .= $this->TraceError(); return false; endif; $logins = @mysql_fetch_object($result); if($logins->total == '0') return false; return true; } -Brian

« previous php.general (#33119) next »