MyBB Community Forums

Full Version: [Tutorial] Integrating MyBB's Login System With Your Website
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
Still needs a 1.6 fix.
I changed the code slightly to use a variable for the forum path instead. I noticed two places which needed the forum path set, so to make it easier to modify, I personally feel a variable is appropriate.

<?php
$path = "forum";
chdir($path); // path to MyBB
define("IN_MYBB", 1);
require("./global.php");
chdir("../");
?>

<?php

if($mybb->user['uid'])
{
    // If the user if logged in, display a welcoming message.
    echo "Welcome back ".$mybb->user['username']."!<br />";
    echo "Thanks for logging in.";
}
else
{
    // If the user is not logged in, display the login form.
    echo "<form action='$path/member.php' method='post'>";
    echo "<input type='hidden' name='action' value='do_login' />";
    echo "<input type='hidden' name='url' value='../index.php' />";
    echo "Username: <input type='text' name='username' maxlength='30' /><br />";
    echo "Password: <input type='password' name='password' /><br />";
    echo "<input type='submit' name='submit' value='Login' />";
    echo "</form>";
}

?>
No matter what I do it won't show me as logged in on my main index.php but shows logged in at the forums. Is this even 1.6 compatible?
i get this error

Fatal error: Cannot redeclare error() (previously declared in /home/site/public_html/includes/incglobal.php:203) in /home/site/public_html/forum/inc/functions.php on line 675
what can i do?
(2010-11-29, 04:36 AM)DigitalMikey Wrote: [ -> ]No matter what I do it won't show me as logged in on my main index.php but shows logged in at the forums. Is this even 1.6 compatible?

Hello,

I encountered the same problem and managed to fix it by changing the cookie path setting via the Admin CP. Here's what you have to do:

1. Go to your MyBB Admin CP and navigate to Settings -> General Configuration -> Cookie Path
2. Change your cookie path one level up. This means that if your cookie path is "/folder1/folder2/", change it to "/folder1/".

I figure this is because MyBB is installed in "/folder1/folder2/" so when you log in and the cookie path is set to that, then the cookie will not be recognized by your browser when you are surfing your website in "/folder1/".

Hope this helps. Smile
Is it possible to add the HTML code as a Wordpress widget?
I assume this opens a possibility of my Post2Host idea. Automatically check their statistics to see if they did what I required.

Muahaha.
can anyone check the OP code whether it will work with 1.8
(2015-05-02, 06:26 PM)Hamster24 Wrote: [ -> ]can anyone check the OP code whether it will work with 1.8

Whenever i change the cookie path from /forums/ to / , after saving it automatically changes this back to /forums/ ..
Anyone has a fix for this? using 1.8
Pages: 1 2 3 4 5