MyBB Community Forums

Full Version: MyBB Integrator Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
OK, so, I don't know if anyone can help me with this problem. I am trying to use the MyBB Integrator found here: http://phpdave.com/MyBBIntegrator/.
I am having a small problem thou.
I am using this:
<?php
define('IN_MYBB', NULL);
require_once 'forum/global.php';
require_once 'class.MyBBIntegrator.php';
$MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang, $config); 

// Auth check when login form is sent (Note: This would also work with Array)
if (isset($MBI->mybb->input['user']) && isset($MBI->mybb->input['pass']))
{
    // Captcha Login
    if (isset($MBI->mybb->input['captcha_hash']))
    {
        // So we have the correct captcha hash from the form
        $login = $MBI->login($MBI->mybb->input['user'], $MBI->mybb->input['pass'], $MBI->mybb->input['captcha_hash'], $MBI->mybb->input['captcha']);
        if (is_array($login))
        {
            // So we have the correct captcha hash in the form
            $captcha_hash = $login['imagehash'];
            echo 'Captcha required<br />';
        }
    }
    // Non-Captcha Login
    else
    {
        $login = $MyBBI->login($MyBBI->mybb->input['user'], $MyBBI->mybb->input['pass']);
        if (is_array($login))
        {
            // So we have the correct captcha hash in the form
            $captcha_hash = $login['imagehash'];
            echo 'Captcha required<br />';
        }
    }
    
    if ($login === true)
    {
        echo 'Login successful';
    }
    else if ($login === false)
    {
        echo 'Login failed';
    }
}

// Let's set up the initial form
echo '<form action="test.php" method="post">';
echo 'Username <input type="text" name="user" value="admin" /><br />';
echo 'Password <input type="password" name="pass" value="Pass" /><br />';
// If the login returns the captcha array, show the captcha in the form
if (is_array($login))
{
    echo '<input type="hidden" name="captcha_hash" value="'.$captcha_hash.'" />';
    echo $login['captcha'].'<br />';
    echo 'Captcha <input type="text" name="captcha" /><br />';
}
echo '<input type="submit" name="login" value="Login" />';
echo '</form>'; 
?>

That is right off PHPDave's site. But it doesn't work. I get a 404 error every time I try to login. I am using a free webhost called http://www.000webhost.com/

I am using the newest version of MyBB. I am trying to use this to integrate the MyBB Login to my website.

Am I missing something or doing something wrong? I have even cleared my cache and tried it again but still nothing. I would post this problem on PHPDave's forum, but I am waiting for a moderator to activate me still.

I would appreciate any help you could give me.

Thanks,
Legobear154
first off, if your forum located in a "forum" folder? If not, you need to edit the location of the global.php file to reflect where your forum actually is relative to where you are applying the integrator.
Yes, I have my forum in a sub-directory called forum. That is something I set because of what the site said.
URL and test account?
(2011-08-11, 03:17 PM)pavemen Wrote: [ -> ]URL and test account?

URL: http://legobear154productions.webuda.com..._login.php

account username: test
account password: test11

Here is the forum: http://legobear154productions.webuda.com/testing/forum/
Your form is pointing to an invalid page
echo '<form action="test.php" method="post">';

you need to edit this line to use the same page you are on.
echo '<form action="mybb_login.php" method="post">';
(2011-08-11, 03:31 PM)pavemen Wrote: [ -> ]Your form is pointing to an invalid page
echo '<form action="test.php" method="post">';

you need to edit this line to use the same page you are on.
echo '<form action="mybb_login.php" method="post">';

I changed it but when I go to my forum it doesn't show that I am online and all it does when I press login is show me the login page again and nothing else. It doesn't say successful or failed or anything.
also looks like the code has a typo. First it creates $MyBBI, but later it uses $MBI. Try changing $MBI to $MyBBI
I could have sworn I changed them all already... Thank you, that fixed it. I should have known that where little mistakes.

Oh, also, how would I set it where the users name who logged in is shown on all pages of my website? What would the easiest way be?

Just thought of one more thing, how could i set it where I don't have to add all the PHP code to do a login. Like where all I have to do is add in the form? Something like this <form name="login" method="post" action="checklogin.php"> ?

Thanks again,
legobear154
I have not really looked into how the integrator works, so I can be of much more help right now.

I would think that you add the same code you have above, from the top to the $MyBBI = new....

Then you can use $MyBBI->mybb->user['username'] as the user's name. Its up to you to code the rest of the HTML/template
Pages: 1 2