MyBB Community Forums

Full Version: Integrating MyBB into your website. (Login Form)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
Edit ** never mind. I figured it out.
You mind telling me your resolution journeyoftheanimals? I'm getting the same problem.
Sure thing. I will show you my code and will highlight in red what you will have to change for your site.



Quote:<?php

if($mybb->user['uid'])
{
// The user is logged in, say Hi
echo "Hey, {$mybb->user['username']}.<br>
Thanks for logging into the forums.";
}
else
{
// The user is not logged in, Display the form
echo "<form action='forums/member.php' method='post'>
Username: <input type='text' name='username' size='25' maxlength='30' /><br />
Password: <input type='password' name='password' size='25' />
<input type='hidden' name='action' value='do_login'>
<input type='hidden' name='url' value='index.php' />
<input type='submit' class='submit' name='submit' value='Login' /></form><br>";
}
?>



Then on the page you are placing the login box on you need to place the following at the very top of the page. I even put it before the <head> tag.

Quote:<?php
chdir('petchat'); // path to MyBB
define("IN_MYBB", 1);
require './global.php';
?>

This code works with version 1.2.9 as of 12/3/07

Any more questions then just ask and I will try to help.

Adam Burgi
www.journeyoftheanimals.com
Hi I have a problem:

This method doesn't seem to be working for 1.2.10.
İt gets the user data but as an unregistered user. I am logged in in the next tab so it have to work, as it was in 1.2.9.

I couldn't figure what has changed in global.php between 1.2.9 and 1.2.10.

Any help will be appreciated.
Get the two and compare them, I think there's a find differences tool in DW (Dreamweaver).
How do i display a custom user field of a user to another user? for example, if i log into my website i want to see another user's real name. the custom field already exists, but i can't seem to figure out how to access it...thanks
i'm still struggling with this and i really need to get it done, so i would really appreciate some help...

here's what i've done so far:

the login script:
<?php

//include the global.php page to allow integration of the forums with the website


chdir('../'); // path to forum relative to current directory
define(IN_MYBB,1);
require './global.php'; //include MyBB global variables


//Login script
if($mybb->user['uid'])
{
	// The user is logged in, say Hi
	echo "Hey, " . $mybb->user['username'] . "! ";

		

	if($mybb->user['usergroup'] == '8')

	{

		//The user is a MACS member
		echo "Welcome to the members area!";

	}

	else

	{

		//The user is not a MACS member

		echo "Our members area is exclusive to MACS members.";

	}

		

	//provide a logout link

	echo " <a href='../member.php?action=logout&uid=" . $mybb->user['uid'] . "&sid=" . $session->sid . "'>Logout</a>.";

}
else
{
	// The user is not logged in, display the login form
	echo 

	"<div class='login'><div class='border'>Welcome, Guest!<br />

	Please login with your forum username and password:<br /><br />

	<form action='../member.php' method='post'>

	<table>

	<tr>

	<td>Username:</td><td><input type='text' name='username' size='25' maxlength='30' /></td>

	</tr>

	<tr>

	<td>Password:</td><td><input type='password' name='password' size='25' /></td>

	</tr>

	<tr>

	<td>
		<input type='hidden' name='action' value='do_login'>
		<input type='hidden' name='url' value='/forum/test/index.php' />

		<br />
		<input type='submit' class='submit' name='submit' value='Login' />

	</td>

	</tr>

	</table>

	</form></div></div>";
}
?>

the members page:
<html>
<head><title>Members Test</title></head>
<body>
<?php
     	//Globals
	//$TABLE_PREFIX = "prefix";
	
	$login = 'login.php'; //path to login page relative to current directory
	//include login.php script
        include $login;
	echo "<br /><br />";
	
	//test whether the user is logged in and is a MACS member
	if($mybb->user['usergroup'] == '8')
	{//the user is loggend in and is a MACS member
		//select database
		$select = mysql_select_db('myForums');
		if (!$select)
		{
			die('Could not select database: ' . mysql_error());
		}
		
		//SQL query to select all macs members from database
		$result = mysql_query("SELECT * FROM " . TABLE_PREFIX . "users WHERE usergroup = '8' ORDER BY username");
		if (!$result)
		{
			die('Query failed: ' . mysql_error());
		}
		
		//create a list of macs members
		$Mcount = 0;
		$Mlist = '';
		
		while ($row = mysql_fetch_object($result))
		{
			$Mcount++;
			$Mlist = $Mlist . $Mcount . ". " . $row->username . " (" . $row->fid4 . ")<br />";
			$Mlist = $Mlist . $row->email . "<br /><br />\n";
			//*** How to access custom user field (fid 8) ????
		}
		
		mysql_free_result($result);
		
		//list of macs members
		echo "There are $Mcount MACS members in our database:<br /><br />\n$Mlist";
	}
	else
	{//the user is not logged in or isn't a MACS member
		echo 'You are not a MACS member, or you are not logged in.';
	}
?>
</body>
</html>

the problem is in line 39 of the members page. I don't know how to access a user's custom profile fields. Can somebody please give me an example?

Thanks!
Hello:

I'm trying to integrate mybb into my website using iframes so I can surround it with top, left and right borders. You can see the results at http://piccone.us/index.asp. The board works properly for the initial loading and if I follow any of the forum or thread links. However, if I try to follow the search, member list, calendar or many other links, the iframe shrinks so most of MyBB is not visible. Is there something about how these other links work that would cause this behavior? Any help would be greatly appreciated.

- John
thank you Wink
Am I doing something wrong? Cause its not working for me... Here's what I'm using.

Quote:<?php
chdir('/home/www/poketech.freehostia.com/forum'); // path to MyBB
require './global.php';
?>

and thats at the top of my html page code (stuff) then later on in the page I added this:

Quote:<?php

if($mybb->user['uid'])
{
��// The user is logged in, say Hi
echo "Hey, $mybbuser[username].<br>
Thanks for logging in.";
}
else
{
��// The user is not logged in, Display the form
echo "<form action='forums/member.php' method='post'>
Username: <input type='text' name='username' size='25' maxlength='30' /><br />
Password: <input type='password' name='password' size='25' />
<input type='hidden' name='action' value='do_login'>
<input type='hidden' name='url' value='index.php' />
<input type='submit' class='submit' name='submit' value='Login' /></form><br>";
}
?>

But it keeps giving me this error:

Quote:Parse error: parse error, unexpected '&' in /home/www/poketech.freehostia.com/test.php on line 221

What am I doing wrong?
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48