redeye
05-28-2006, 09:35 PM
I need help in getting password authentication to work for my website.
I had written the function below and it worked fine on the old version of mysql but not on the newer one. I changed the password field to accommodate 41 chars hoping that was the only change I had to make but it still doesn't work.
Below is the function and info about the password field.
Thanks in advance for your help.
My database
Field Type
username varchar(16)
password varchar(41)
email varchar(100)
-------------------------------------------------
My login function
function login($username, $password)
// check username and password with db
// if yes, return true
// else return false
{
// connect to db
$conn = db_connect();
if (!$conn)
return false;
// check if username is unique
$result = mysql_query("select * from user
where username='$username'
and password = password('$password')");
if (!$result)
return false;
if (mysql_num_rows($result)>0)
return true;
else
return false;
}
I had written the function below and it worked fine on the old version of mysql but not on the newer one. I changed the password field to accommodate 41 chars hoping that was the only change I had to make but it still doesn't work.
Below is the function and info about the password field.
Thanks in advance for your help.
My database
Field Type
username varchar(16)
password varchar(41)
email varchar(100)
-------------------------------------------------
My login function
function login($username, $password)
// check username and password with db
// if yes, return true
// else return false
{
// connect to db
$conn = db_connect();
if (!$conn)
return false;
// check if username is unique
$result = mysql_query("select * from user
where username='$username'
and password = password('$password')");
if (!$result)
return false;
if (mysql_num_rows($result)>0)
return true;
else
return false;
}