Hello all --
I have searched the forums and I did find the Mybb Integration script by phpDave located here :
http://phpdave.com/MyBBIntegrator/Start
My problem is this I am really new to php and am just learning. I've read the documentation etc and it doesn't say where to add the script or how to add the call functions to your page.
Basically I have my forums located at
www.mysite.com/board. On my main page,
www.mysite.com I want to put the mybb login box. I want it to also show user info once a user has logged in.
I cannot figure this out and I'm sure it's simple and is just a matter of me being green with php still and not knowing what exactly to do or where to put what.
Any help would be GREATLY appreciated
Thank you!
Its really easy to put a login box on your main page,
Note: [i] I just copy-pasted this form code so change the HTML yourself
<form method="post" action="member.php">
<table border="0" width="100%">
<tr>
<td>
<label for="login_username">Username:</label>
</td>
<td>
<input type="text" value="" style="width: 200px;" maxlength="30" size="25" name="username" class="textbox" id="login_username" />
</td>
</tr>
<tr>
<td>
<label for="login_password">Password:</label>
</td>
<td>
<input type="password" value="" style="width: 200px;" size="25" name="password" class="textbox" id="login_password" />
</td>
</tr>
<tr>
<td>
<label class="smalltext" title="If ticked, your login details will be remembered on this computer, otherwise, you will be logged out as soon as you close your browser."><input type="checkbox" value="yes" checked="checked" name="remember" class="checkbox"> Remember?</label>
</td>
<td>
<input type="submit" value="Login" name="submit" class="button" />
</td>
</tr>
</table>
<input type="hidden" value="do_login" name="action" />
<input type="hidden" value="" name="url" />
</form>
The main form tags that do the login magic are:
1. <input type="hidden" value="do_login" name="action" />
2. <form method="POST" action="member.php">
3. <input type="text" name="username" />
4. <input type="password" name="password" />
To show user info, you need to somehow include global.php file
Perhaps, this should work:
1. Create a new page say mypage.php & this to it:
<?php
/* *
*
* Code Written By : CEDRIC
* Redistribution : Disallowed
* Date : 21 July 2013
*
*/
$root = $_SERVER['DOCUMENT_ROOT']
@require_once $root."/global.php";
define("IN_MYBB", 1);
// Define your page
define('THIS_SCRIPT', 'mypage.php');
// Rest of the code goes here
?>
Using USER Variables to display user data:
1. Username: $mybb->user['username']
2. Uid: $mybb->user['uid']
3. Email: $mybb->user['email']
4. Avatar: $mybb->user['avatar']
etc :)
If you experience problems, just post again
@Leefish,
Thanks for providing the link
@Mags,
If you encounter any problems like these:
Fatal error: Call to a member function AAAA on a non-object in YYYY on line XXX
You just need to make sure AAAA's class is defined.
Example:
Error:
Fatal error: Call to a member function parse_badwords() on a non-object in /home/****/public_html/index.php on line 123
Fix:
if(!is_object($parser))
{
$parser = new postParser;
}
Thank you so much! This worked, however! What I'd like to have happen is when a user logs in on that external page the page shows them logged in and their info to the left rather than forwarding users to the main forum page. Does that make sense?
That's easy too
You can do this by:
<?php
/* *
*
* Code Written By : CEDRIC
* Redistribution : Disallowed
* Date : 21 July 2013
*
*/
$root = $_SERVER['DOCUMENT_ROOT']
@require_once $root."/global.php";
define("IN_MYBB", 1);
// Define your page
define('THIS_SCRIPT', 'mypage.php');
// If user is a guest
if(!$mybb->user['uid'])
{
//Include the login code here since this will be ONLY shown to guests
}
// This will work for ONLY LOGGED IN Users :D
else
{
$string = "Hello {$mybb->user['username']}!";
echo $string;
}
?>
Thanks Cedric! Now would this bit of code replace the previous one that you gave me? If so, I did that and I got an error of: Parse error: syntax error, unexpected '@' in /home/boards/index.php on line 49 where line 49 reads : @require_once $root."/board/global.php";
Remove the @ in front of require_once to fix the error.
@down, oh right, didn't notice the missing semicolon.
@Destroyer666,
Wrong. '@' suppresses errors.
@mags,
Sorry my bad
Fogot to put semi colon
Here is the correct code:
<?php
/* *
*
* Code Written By : CEDRIC
* Redistribution : Disallowed
* Date : 21 July 2013
*
*/
$root = $_SERVER['DOCUMENT_ROOT'];
@require_once $root."/global.php";
define("IN_MYBB", 1);
// Define your page
define('THIS_SCRIPT', 'mypage.php');
// If user is a guest
if(!$mybb->user['uid'])
{
//Include the login code here since this will be ONLY shown to guests
}
// This will work for ONLY LOGGED IN Users :D
else
{
$string = "Hello {$mybb->user['username']}!";
echo $string;
}
?>
Do I replace the first bit of code with this, or does this go elsewhere in the page? Thank you again!!