MyBB Community Forums

Full Version: Website Integration Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
OK, so I am curious, how could I add in a login form on my website, separate of MyBB, and have it where you can enter the username and password you used to register on my MyBB forum. I also would want it so you don't have to login again when you change between the main site and the forum.

I have this and it sorta works:

<?php
$dbhost = 'host';
$dbuser = 'user';
$dbpass = 'pass';
$tbl_name = 'users';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db('forum')or die('cannot select DB');

        $user = $_POST['user'];
        $pass = $_POST['pass'];
				$query = "SELECT salt FROM $tbl_name WHERE username='$user'"; 
				$result = mysql_query($query) or die ('salt query failed');
				$row = mysql_fetch_assoc($result);
				$salted = $row['salt'];
				$hashed_password = md5($pass);
				$saltedpw = md5(md5($salted).$hashed_password); 
				$sql="SELECT * FROM mybb_users WHERE username='$user' and password='$saltedpw'";
				$result=mysql_query($sql);

				// Mysql_num_row is counting table row
				$count=mysql_num_rows($result);

if ($count == 1) {
	 echo "Login Successful";
	 mysql_query($sql);
}
else {
		 echo "Login Failed";
}
?>
It does show successful when username and password entered is correct. I do know that it would have something to do with cookies and sessions. I am just not sure how to do it. So could anyone explain how to or give me code or something?

Also, if there is an easier/ quicker way to do what I have done above I would be happy to learn how.

Thanks,
Legobear154
Wish this was an answer... but it's just a "me too" - I'm looking to do the same thing. Any luck yet?
Thanks for the quick reply. I found this right after posting:

http://community.mybb.com/thread-60422.html