MyBB Community Forums

Full Version: Website Intergration to Mybb.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, 

I would love to have my "Website" Which is not a CMS or anything. It's a normal Website. I need to have the login to go with my forum so that it would be one single sign on so people would not have to register again to the forum after registering to the site. Here is my login code from my site. Not from MyBB and I use current MyBB


<?php
ini_set('display_errors', 'On');
/* Program: login.php (login)
 * Desc: Login for database, duh.
 */
              session_start();
              include("site-inc/gamengdb.php");
              switch (@$_GET['do'])
	{
		case "login":
                        $fusername = addslashes(trim($_POST['fusername']));
                        $fpassword = addslashes(trim($_POST['fpassword']));
			$sql = "SELECT log_name FROM game_data WHERE log_name='$fusername'";
			$result = mysqli_query($connection, $sql) or die ("Could not execute query.<br>".mysqli_error($sql)."<br>");
			$num = mysqli_num_rows($result);
			if ($num == 1)	// login name was found
			{
                                  $sql = "SELECT log_name,password,user_privilege FROM game_data WHERE log_name='$fusername' AND password='$fpassword'";
				 $result2 = mysqli_query($connection, $sql) or die ("Could not execute query.<br>".mysqli_error($connection)."<br>");
				 $num2 = mysqli_num_rows($result2);
				 if ($num2 > 0)	// password is correct
				 {
					 $row=mysqli_fetch_array($result2);
                                         $logname=$fusername; 
                                         $privilege=$row['user_privilege'];
                                         $st_flag=$row['st_flag'];
                                         setcookie('logname',$logname,time()+(60*60*24*1),'/','www.thesecretsocietychronicles.com');
                                         setcookie('privilege',$privilege,time()+(60*60*24*1),'/','www.thesecretsocietychronicles.com');
                                                if ($st_flag=="yes"){
                                         setcookie('st_flag',$st_flag,time()+(60*60*24*1),'/','www.thesecretsocietychronicles.com');
                                         } else { }
                                         $query = "UPDATE game_data SET last_login=NOW() WHERE (log_name='$fusername')";
                                         $result = mysqli_query($connection, $query) or die ("Could not execute query.<br>".mysqli_error($connection)."<br>");
					         header("Location: index.php");
				 }
				 else		// password is not correct
				 {
					 unset($do);
					 $message="<p class='error'>Incorrect password.</p>";
					 include("login_form.inc");
				 } 
			}
			elseif ($num == 0)	// login name not found
			{	 
				 unset($do);
				 $message = "<p class='error'>User does not exist.</p>";
				 include("login_form.inc");
			}
		break;
		default:
				include("login_form.inc");
	}
?>
I have read a lot of areas on how to do this, but I'm not survey in this type of stuff. I'm learning but very slowly. If someone could paint me a picture on how to do this, by simply giving me instructions, what goes where and how.

Thank you
Kitty.
Why not use the mybb login system instead ? Import your users to mybb and replace your system.