what is wrong with this login script?
| From: | Jacky | Date: | Fri, 27 Apr 2001 14:45:27 +0000 |
| Subject: | what is wrong with this login script? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-50545@lists.php.net to get a copy of this message | ||
Hi all
I tried to make a login function for my site using script below, but after I type user name and
password, it asked me to type again and again and simply reject it, although I have made sure that
the username and password I used to test is in the table for sure. No database connection probelm
for sure as well.
if(!($PHP_AUTH_USER)):
Header("WWW-authenticate: basic realm=Restricted Area");
Header("HTTP/1.0 401 Unauthorized");
echo "<meta http-equiv=\"refresh\" content=\"0;url=failed.
php3\">";
exit;
else:
$connection = mysql_connect("localhost", "username", "password")or
die("connection fail");
if (!$connection) {echo "An error occurred in connection.\n";
exit;}
mysql_select_db("manageasy", $connection);
$user_id=$PHP_AUTH_USER;
$password=$PHP_AUTH_PW;
$result = mysql_query("SELECT hotel_id,username,password FROM hotels WHERE username =
'$user_id' AND password='$password'", $connection);
Jack
jacky@activelifestyle.com
"There is nothing more rewarding than reaching the goal you set for yourself"