authenticating users with php&mysql
| From: | it clown | Date: | Wed, 26 Jan 2005 10:44:38 +0000 |
| Subject: | authenticating users with php&mysql | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-38354@lists.php.net to get a copy of this message | ||
Hi All,
I am trying to create a page with 2 text boxes a name and a
password with a submit button.The user must enter his
username and password that is stored in mysql to access the
site.
With the following code i get a successfull connection with
a blank username and password but when i enter a wrong
username and password i get a error that is correct.
<html>
<head><title>MySQL Connection</title></head>
<body>
<div align="centre">
<form action="<?php echo $_SERVER[PHP_SELF];
?>" method="POST">
Name: <input type="text"
name="txt_name">
Password: <input type="text"
name="txt_password">
<br /><input type="submit" value="Submit">
</div>
</form>
</body>
</html>
<?php
$db_host = "localhost";
$db_user = $_POST["txt_name"];
$db_password = $_POST["txt_password"];
$db_name = "data";
$connection = @mysql_connect ($db_host, $db_user,
$db_password) or die ("error connecting");
echo "connection successful!";
?>
What is the best way to authenticate users against mysql
for login?
Regards
______________________________________________________________
http://www.webmail.co.za the South African FREE email service