PDA

View Full Version : login to vb database



blazes
August 1st, 2006, 05:02 AM
Hey everyone. I have a vBulletin database and i'm making a login page to login, using the usernames and passwords from the database. The md5 hashes come out differently when I press login, than whats in the database. I need to know how to fix this. cuz i'm confused.


$username = trim(addslashes($_POST['username']));
$password = md5(trim($_POST['password']));
$query = mysql_query("SELECT * FROM tablename WHERE username = '$username' AND password = '$password' LIMIT 1") or die(mysql_error());
$row = mysql_fetch_array($query);

bigmtnskier
August 1st, 2006, 01:54 PM
vBulletin passwords are stored as md5(md5(password) . salt); so that two stored passwords that are the exact same aren't aren't the same.

So, the PHP would look like this:



$username = trim(addslashes($_POST['username']));
$password = trim($_POST['password']);
$query = mysql_query("SELECT * FROM tablename WHERE username = '$username' LIMIT 1") or die(mysql_error());
$row = mysql_fetch_array($query);
if ($row['password'] == md5(md5($password) . $row['salt'])){
//successful login
}else{
//login failed
}


-bigmtnskier :hugegrin:

blazes
August 1st, 2006, 06:15 PM
Thank you so much! I wondered what salt was for.