MyBB Community Forums

Full Version: Using MyBB User DB for External Script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to integrate a script with mybb. I want to use mybb for the user database and registration. I'm trying to get the user info. I'm not sure how to do this with the MD5 and SALT.

Currently it looks like this:

$user_info = mysql_fetch_assoc(mysql_query("SELECT * FROM plgk WHERE email='$email' AND password='$password'"));

I tried changing it to this but it didn't work:

$user_info = mysql_fetch_assoc(mysql_query("SELECT * FROM mybb_users WHERE email='$email' AND password=MD5('$password')"));
Try using this.
$query = mysql_query("SELECT * FROM mybb_users WHERE email='$email'");
$user = mysql_fetch_assoc($query);
$input_pw = md5(md5($password).md5($user['salt']));
if($input_pw == $user['password'])
{
     $user_info = $user;
}
Can I use $input_pw as the 'decrypted' password. Trying to get this statement to work:

OLD
if(mysql_num_rows(mysql_query("SELECT * FROM plgk WHERE email='$email' AND password='$password'")) == 0) {
$is_error = "yes";
$error = "The login information you have provided is invalid.";


NEW
if(mysql_num_rows(mysql_query("SELECT * FROM mybb_users WHERE email='$email' AND password='$input_pw'")) == 0) {
$is_error = "yes";
$error = "The login information you have provided is invalid.";
matt604 Wrote:Can I use $input_pw as the 'decrypted' password. Trying to get this statement to work:

OLD
if(mysql_num_rows(mysql_query("SELECT * FROM plgk WHERE email='$email' AND password='$password'")) == 0) {
$is_error = "yes";
$error = "The login information you have provided is invalid.";


NEW
if(mysql_num_rows(mysql_query("SELECT * FROM mybb_users WHERE email='$email' AND password='$input_pw'")) == 0) {
$is_error = "yes";
$error = "The login information you have provided is invalid.";

$input_pw is the encrypted password, and if you mean it as such, then your snippet above should work, if you put it something like this:

$query = mysql_query("SELECT * FROM mybb_users WHERE email='$email'");
$user = mysql_fetch_assoc($query);
$input_pw = md5(md5($password).md5($user['salt']));
if($input_pw == $user['password'])
{
     $user_info = $user;
}
if(mysql_num_rows(mysql_query("SELECT * FROM mybb_users WHERE email='$email' AND password='$input_pw'")) == 0) {
$is_error = "yes";
$error = "The login information you have provided is invalid.";