Integrating MyBB with existing website!
#1
Hi everyone!

I have ben trying to integrate a forum to my site with no success at all!

I want when a member join my site, he gets added to the forum as well, and when he login into my site he also gets logged in the forum too.

for the old members of my site, I can add them to the data base of the forum, just having issues with new members and login part.


here is the signup code for my site:

<table border=0 width=100% cellspacing="5" cellpadding="5" align="center"><tr>
<td colspan=2 align=center>If you only wish to advertise with us and do not wish become an affiliate, check this box <input type=checkbox name="userform[account_type]" value='advertiser' <? userform('account_type')?>><br>Advertiser accounts will not receive paid emails nor will they receive any of the benifits that are given to affiliates</td></tr>
<td>Username:<br><font size=1>Use letters and numbers only</font></td>
<td><input type="text" name="userform[username]" maxlength=16 value="<script language="php">
userform("username");</script>"></td>
</tr><tr> 
<td>E-Mail:</td>
<td><input type=hidden name="userform[email]" value="<script language="php"> userform("email");</script>">
<script language="php"> userform("email");</script></td>
</tr><tr>
<td><div align="left">Send emails to:</div></td><td>
<select name=userform[email_setting]>
<script language="php"> new_member_email_setting();</script>
</select>
</td></tr><tr> 
<td>First Name:</td>
<td><input type="text" name="userform[first_name]" value="<script language="php">
userform("first_name");</script>"></td>
</tr><tr> 
<td>Last Name:</td>
<td>  
<input type="text" name="userform[last_name]" value="<script language="php">
userform("last_name");</script>"> </td>
</tr><tr> 
<td>Address:</td>
<td>  
<input type="text" name="userform[address]" value="<script language="php">
userform("address");</script>"> </td>
</tr><tr> 
<td>City:</td>
<td>  
<input type="text" name="userform[city]" value="<script language="php">
userform("city");</script>"> </td>
</tr>
<tr> 
<td>State:</td>
<td><select name="userform[state]"><option value=''>Please select your state
<script language="php"> new_member_states();</script>
</select>
<br>Other: <br>                                         
<input type="text" name="userform[state_other]" value="<script language="php"> userform("state_other");</script>"></td>
</tr><tr> 
<td>Zip Code:</td>
<td><input type="text" name="userform[zipcode]" value="<script language="php">
userform("zipcode");</script>"></td>
</tr>
<tr> 
<td>Country:</td>
<td>  
<select name="userform[country]"><option value=''>Please select your country
<script language="php"> new_member_countries();</script>
</select>
</td>
</tr>
<tr> 
<td>Referred by:</td>
<td><input type=text name=refid value="<script language="php"> referrer();</script>"> <br>(If no referrer, a GoldAffiliate will be assigned)</td>
</tr>
<tr> 
<td colspan=2> 
<hr>
</td>
</tr><tr> 
<td colspan=2 align=center> Select categories of interests to 
you:<br><br>
<table border="0" cellspacing="1" cellpadding="1" width="100%">
<script language="php"> new_member_keywords();</script>
</table></td></tr><tr> 
<td colspan=2><hr></td>
</tr><tr> 
<td colspan=2 align=center>  
<select name=userform[pay_type]>
<option value='' selected>Select a payment method 
<script language="php"> new_member_paytypes();</script>
</select></td>
</tr><tr> 
<td colspan=2 align=center>Payment account ID:<br>
<input type=text size=25 value="<script language="php">
userform("pay_account");</script>" name=userform[pay_account]> </td>
</tr><tr> 
<td colspan=2><hr></td>
</tr><tr> 
<td>Password:</td>
<td><input type=password name=userform[password]></td>
</tr><tr>
<td>Confirm Password:</td>
<td><input type=password name=userform[confirm_password]></td>
</tr><tr> 
<td colspan=2 align=center><input type="submit" value="Signup"></td>
</tr></table></form><br></td></tr></table>

and the login code is:

<p align="center"><b>Log In</b> </p>
<form method=post>
<div align="center">
<table border=0>
<tr> 
<td> 
<p>Username or eMail address:</p>
</td>
<td> 
<input type=text name=username>
</td>
</tr>
<tr> 
<td> 
<p>Password:</p>
</td>
<td> 
<input type=password name=password>
</td>
</tr>
<tr> 
<td colspan=2 nowrap> 
<p>Use Auto-login 
<input type=checkbox checked name=autologin value=1>
<br>
Secure your PHPSESSIONs? 
<input type=checkbox checked name=ipsec value=1>
<br>
(not compatible with some Internet providers)<br>
<br>
<input type=submit value="Login" name="submit">
</p>
</td>
</tr>
</table>
</div>
<p align="center"><b><a href="<script language="php"> pages_url();</script>lost_login.php">(Forgot 
your password/ID?)</a></b> </p>
</form>


Hope you can guide me step by step on how to integrate a MyBB forum to my site ,
Reply
#2
Check out this http://phpdave.com/MyBBIntegrator/

It has everything you'll need to integrate your mybb forum into your cms.

A simple login function would look like this:

<?php
define('IN_MYBB', NULL);
global $mybb, $lang, $query, $db, $cache, $plugins, $displaygroupfields;
require_once '/path/to/mybb_forum/global.php';
require_once '/path/to/MyBBIntegrator.php';
$MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang, $config);

if ($MyBBI->isLoggedIn() === false){
echo '<form id="myloginform" method="post" action="login.php">
<label>Username</label><input type="text" name="username" />
<label>Password</label><input type="password" name="password" />
<input type="submit" name="Login" />
</form>';

/* Was the submit button pressed? If so, do the login routine */
if (isset($_POST['Login'])){
$logmein = $MyBBI->login($_POST['username'], $_POST['password']);
if ($logmein == true) echo 'Logged in successfully';
else echo 'The login routine failed';
}
else{
echo 'Hello, ', $MyBBI->mybb->user['username'], '. You're already logged in.';
} 
?>
Give me reputation if you find my replies helpful

MODx, I'd recommend you to use it, you'll save time in your development.
Reply
#3
Hi!

Where should I put that code?
Where should I add that bridge (MyBBIntegrator.php) ?

Also I need what code I should add to my original login.php and signup.php so it wan be linked to the forum?

What I mean is: when a member join my site, he gets automaticly added to the forum as well, when login or log out the site, the smae thing also happen in the forum.

Hope this will help you to guide me solve this !

Thanks for all your efforts.
Reply
#4
(2012-08-06, 10:17 PM)phpjunky Wrote: Hi!

Where should I put that code?
Where should I add that bridge (MyBBIntegrator.php) ?

Also I need what code I should add to my original login.php and signup.php so it wan be linked to the forum?

What I mean is: when a member join my site, he gets automaticly added to the forum as well, when login or log out the site, the smae thing also happen in the forum.

Hope this will help you to guide me solve this !

Thanks for all your efforts.

Put your MyBBIntegrator.php file in the root directory of your site.

Basically, It's pretty simple to do what you're requesting.

For example, lets say we have a page where you enter your username and password and then submit the form, lets create a php file in your root directory and name it to "login.php", include the following code in the page:

<?php
define('IN_MYBB', NULL);
global $mybb, $lang, $query, $db, $cache, $plugins, $displaygroupfields;
require_once '/path/to/mybb_forum/global.php';
require_once '/path/to/MyBBIntegrator.php';
$MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang, $config);

// The html code embedded into php by using a simple echo //
echo '<form id="mybb-login" method="post" action="', $_SERVER['PHP_SELF'], '">
Username: <input type="text" name="username" /><br />
Password: <input type="password" name="password" /><br />
<input type="submit" name="login" value="Login" />';

// This will check whether the input (submit button) has been pressed to prevent the login function from firing once the page is loaded  //
if (isset($_POST['login'])){
$logmein = $MyBBI->login($_POST['username'], $_POST['password']);
if ($logmein == true) echo 'Logged in successfully';
else echo 'The login routine failed';
}
else{
echo 'Hello, ', $MyBBI->mybb->user['username'], '. You're already logged in.';
} 
?>

Remember to adjust the require_once paths.
Give me reputation if you find my replies helpful

MODx, I'd recommend you to use it, you'll save time in your development.
Reply
#5
Hi again!

the first part is working!

Now I have 2 problems :

* Importing the old members from the main site to the forum data base: on the site db the pasword is hashed, but on the forum you see 3 parts for the password: password, salt, loginkey, and even the password hash doesn't look like the one my main site uses! I tried using same password on forum and my site to compair and it was different, so how can I solve it?
example: the password "demo123" looks like this on forum:


password: 2e5d6215cf6a7bff87f787fef2f8ff46

salt: 7PW2sXwH

loginkey: ZA76HsrEdiemElGwP6tUvvGXfKMyAiUTJX5hoVSdNhLTy5uBsX
but on my site :

password: 62cc2d8b4bf2d872

* Adding the new members that join from the main site to the db of forum as well: this that I can't find how to do it !


Hope you can help in this one as well!

Thanks a lot
Reply
#6
I too have a similar problem. I am creating a website which has a mybb forum plus a mysql db wherein the users can search, upload or download files. I have made those php pages for search, etc. They are in "public_html/root" folder. Mybb forum files are in "public_html/root/Forum" folder.
I want to put a script on my homepage and the other pages showing the login info about user. I tried pasting the code above my script, it shows the script itself. If I make a separate form, then it works, showing that I have put the refs and the Integrator files in proper way. Sorry but I am an absolute newbie.
If it is not too much to ask, I'd also like the user to be allowed download only if he is logged in.
Reply
#7
(2012-08-10, 11:29 PM)phpjunky Wrote: Hi again!

the first part is working!

Now I have 2 problems :

* Importing the old members from the main site to the forum data base: on the site db the pasword is hashed, but on the forum you see 3 parts for the password: password, salt, loginkey, and even the password hash doesn't look like the one my main site uses! I tried using same password on forum and my site to compair and it was different, so how can I solve it?
example: the password "demo123" looks like this on forum:


password: 2e5d6215cf6a7bff87f787fef2f8ff46

salt: 7PW2sXwH

loginkey: ZA76HsrEdiemElGwP6tUvvGXfKMyAiUTJX5hoVSdNhLTy5uBsX
but on my site :

password: 62cc2d8b4bf2d872

* Adding the new members that join from the main site to the db of forum as well: this that I can't find how to do it !


Hope you can help in this one as well!

Thanks a lot

Are you using any kind of CMS like Joomla or Wordpress?

Once a password has been salted and encrypted in a specific encryption method it canno't be used in another system which has a different encryption method, you will simply need to tell your users to reset the password from the main site and encrypt your password in the process in md5 (salted). You can find the functions for mybb's password hashing methods in /inc/functions_user.php.
Give me reputation if you find my replies helpful

MODx, I'd recommend you to use it, you'll save time in your development.
Reply
#8
Is it possible to integrate with myBB forum if the website and myBB forum are hosted on different domains?
Reply
#9
(2012-08-23, 01:49 AM)brianmccoy Wrote: Is it possible to integrate with myBB forum if the website and myBB forum are hosted on different domains?

I doubt it! Why would you want to do that, unless the other domain is a subdomain like forums.yourdomain.com?
I fold for team 52482. Do you fold?
Reply
#10
(2012-08-23, 12:58 PM)MadComp Wrote:
(2012-08-23, 01:49 AM)brianmccoy Wrote: Is it possible to integrate with myBB forum if the website and myBB forum are hosted on different domains?

I doubt it! Why would you want to do that, unless the other domain is a subdomain like forums.yourdomain.com?

my forum is existing one (popular with traffic) with a good user database, but i'm opening another new site, so I cud utilize that user db on my new site if user db & registration can be integrated with the forum.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)