note 80687 added to features.http-auth

From: Date: Tue, 29 Jan 2008 10:43:34 +0000
Subject: note 80687 added to features.http-auth
Groups: php.notes 
Request: Send a blank email to php-notes+get-135501@lists.php.net to get a copy of this message
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! ---- Server IP: 69.147.83.197 Probable Submitter: 195.170.52.99 ---- Manual Page -- http://www.php.net/manual/en/features.http-auth.php Edit -- https://master.php.net/note/edit/80687 Del: integrated -- https://master.php.net/note/delete/80687/integrated Del: useless -- https://master.php.net/note/delete/80687/useless Del: bad code -- https://master.php.net/note/delete/80687/bad+code Del: spam -- https://master.php.net/note/delete/80687/spam Del: non-english -- https://master.php.net/note/delete/80687/non-english Del: in docs -- https://master.php.net/note/delete/80687/in+docs Del: other reasons-- https://master.php.net/note/delete/80687 Reject -- https://master.php.net/note/reject/80687 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135501) next »