note 80687 deleted from features.http-auth by felipe

From: Date: Tue, 29 Jan 2008 11:31:06 +0000
Subject: note 80687 deleted from features.http-auth by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-135532@lists.php.net to get a copy of this message
Note Submitter: helenochka at comtv dot ru ---- Hello! My Authenticate doesn't work <?php /* config */ $db_name = "dbname"; $table = "users"; $host = "localhost"; $user = "root"; $pwd = ""; $link = mysql_connect($host, $user, $pwd) or die (mysql_errno($link).mysql_error($link)); $db = mysql_select_db($db_name, $link) or die (mysql_errno($link).mysql_error($link)); //$login = $_SERVER['PHP_AUTH_USER']; //$pass = $_SERVER['PHP_AUTH_PW']; header("WWW-Authenticate: Basic realm = \"Welcome!\""); $sql_query = ("SELECT count(*) FROM users WHERE login = \"$_SERVER['PHP_AUTH_USER']\""); $result = mysql_query($sql_query); $data = mysql_fetch_array($result); if($data[0] > 0) { $sql_query = ("SELECT * FROM users WHERE login = \"$_SERVER['PHP_AUTH_USER']\""); $result = mysql_query($sql_query, $link) or die (mysql_errno($link).mysql_error($link)); $password = mysql_fetch_array($result); if($password[0] != $_SERVER['PHP_AUTH_PW']) { echo("Incorrect Pass!"); } else { session_start(); header('Location: closed.php'); } } else { echo("Invalid Username!<br><a href = \"idx.phtml\">Back!</a>"); } mysql_close(); ?> What should I do to make it work? Please help!

« previous php.notes (#135532) next »