md5('$password')
| From: | bryan | Date: | Wed, 18 Oct 2000 22:53:39 +0000 |
| Subject: | md5('$password') | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-3772@lists.php.net to get a copy of this message | ||
Hey...
This here is my code. Its a function to log a user on from the table I
created called 'auth'. Umm, like before, I am trying to use encrypted
passwords by using VALUES(0,'bryan', md5('password'); in my SQL statement.
When I go to log in, I am wanting to use the password 'password', and not
the encrypted one (duh!) So, to do this, would I just put in my query
$sql = "SELECT * FROM auth WHERE username='$username' AND
password=md5('$password')";
or, is there something else I am missing? Thanks for the help!
Bryan
/* code starts
<?php
function logon($username, $password) {
if (!($link = mysql_connect("localhost:/var/lib/mysql/mysql.sock",
"MySql", ""))) {
echo "Could not log you on!";
return 0;
}
$sql = "SELECT * FROM auth WHERE username='$username'";
if (!($result = mysql_db_query("test", $sql, $link))) {
echo "SQL problem!" ;
return 0;
}
$row = mysql_fetch_array($result);
if ($password) == $row[3]) && ($password) != "")) {
return 1;
} else {
return 0;
}
}
if (logon($username, $password)) {
session_start();
session_register('username');
header("Location: http://www.somewhere.com/test.php");
exit();
} else {
header("location: http://www.somewhere.com/error.html");
exit();
}
?>
code ends */