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
I have done as suitable and the session correctly works.
The code
echo "Hey, $mybbuser[username]. <br> "
, however, don't stamp the name of the user.

Where I am wrong?
(2008-12-13, 09:06 AM)freedom Wrote: [ -> ]I have done as suitable and the session correctly works.
The code
echo "Hey, $mybbuser[username]. <br> "
, however, don't stamp the name of the user.

Where I am wrong?

Hello!

Actually you'd better use this code:
echo "Hey, {$mybb->user['username']}. <br> "

Hope it helps.
This code has worked out great for me, with one exception. On my website, I changed all of the pages from HTML to PHP so that you can login from any page. I have a page on my site that was already in PHP, and does not want to co-exist with the PHP code you wrote in the initial post.

Here is the PHP header:
<?php
include('_config.php');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

and later, the code.....
<?php
$sql2 = "SELECT
			*
		FROM		_members		 
		WHERE		active = 1
		ORDER BY	company  ASC";
$qid2 = db_query($sql2);
$limit = db_num_rows($qid2);
//$limit--;
$randNum = rand(0,$limit);

if (db_num_rows($qid2) >= 1) {

	for ($a2=0; $a2<db_num_rows($qid2); $a2++) {
		list($id,$firstname,$lastname,$company,$phone,$email,$website) = db_fetch_row($qid2);
			if ($randNum == $id) {
				echo '<table width="100%" border="0" cellspacing="0" cellpadding="3">
						<tr>
							<td width="100%" valign="middle" style="font-size:16px;background-color:#88a6d5;border:2px solid #666;font-size:13px;padding:10px;text-align:center;">
				<h2 style="font-size:19px;color:#fff;margin-bottom:6px;">'.$company.'</h2>
					<strong>'.$firstname.' '.$lastname.'</strong><br>
					'.$phone.'<br><br>';
					if (!empty($email)) { echo '<img src="images/email_med.gif" style="margin-bottom:-3px;"> <a href="mailto:'.$email.'" style="font-size:13px;text-decoration:none;color:#fff;">E-mail</a>&nbsp;&nbsp;'; }
					if (!empty($website)) { echo '<img src="images/home_med.gif" style="margin-bottom:-3px;"> <a href="http://'.$website.'" target="_blank" style="font-size:13px;text-decoration:none;color:#fff;">Website</a>'; }
				echo '</tr></td></table>';
			}
	}
}
?>

<table width="100%" border="0" cellspacing="0" cellpadding="3">
	<tr>
		<td width="50%" valign="top" style="font-size:11px;"> 

<?php
$sql = "SELECT
			*
		FROM		_members		 
		WHERE		active = 1
		ORDER BY	company  ASC";
$qid = db_query($sql);
$howmany = db_num_rows($qid);
$half = number_format($howmany / 2);

$counter = 0;

if (db_num_rows($qid) >= 1) {

	for ($a=0; $a<db_num_rows($qid); $a++) {
		list($id,$firstname,$lastname,$company,$phone,$email,$website) = db_fetch_row($qid);
			echo '
			<div style="padding-bottom:12px;border-bottom:1px solid #cccccc;">
				<h2 style="font-size:14px;color:#6C8CBF;margin-bottom:6px;">'.$company.'</h2>
				<strong>'.$firstname.' '.$lastname.'</strong><br>
				'.$phone.'<br><br>';
				if (!empty($email)) { echo '<img src="images/email.gif"> <a href="mailto:'.$email.'" style="font-size:11px;text-decoration:none;color:#666;">E-mail</a>&nbsp;&nbsp;'; }
				if (!empty($website)) { echo '<img src="images/home.gif"> <a href="http://'.$website.'" target="_blank" style="font-size:11px;text-decoration:none;color:#666;">Website</a>'; }
			echo '</div>';
			$counter++;
			if ($counter == $half) { echo '</td><td width="20">&nbsp;</td><td width="50%" valign="top" style="font-size:11px;">'; }
	}
}
?>
</td>
	</tr>
</table>

<!--
<table width="100%" border="0" cellspacing="0" cellpadding="6">
	<tr>
		<td width="350"><h4>Company Name</h4></td>
		<td><h4>Name</h4></td>
		<td><h4>Office</h4></td>
		<td><h4>Email</h4></td>
		<td><h4>Website</h4></td>
	</tr>
<?php
$sql = "SELECT
			*
		FROM		_members		 
		WHERE		active = 1
		ORDER BY	company  ASC";
$qid = db_query($sql);

if (db_num_rows($qid) >= 1) {

	for ($a=0; $a<db_num_rows($qid); $a++) {
		list($id,$firstname,$lastname,$company,$phone,$email,$website) = db_fetch_row($qid);
			echo '
			<tr>
				<td width="350">'.$company.'</td>
				<td>'.$firstname.' '.$lastname.'</td>
				<td>'.$phone.'</td>
				<td><a href="mailto:'.$email.'">'.$email.'</a></td>
				<td><a href="http://'.$website.'" target="_blank">'.$website.'</a></td>
			</tr>';
	}
}
?>

The actual page in question is:

http://www.bapva.com/members.php

Any ideas on how to make these co-exist on the same page? Right now, I just have a link to the forum...
Hi all,

I'm currently trying to do a site-forum integration using a forum that uses MyBB 1.4.4 (current at the time of writing). I'm currently using the following code, which is essentially taken from the very first post here, because it seems to be the most solid. Does anyone know how I could possibly amend this in order to make it fully compatible with MyBB 1.4.x? At the moment, the script works, but it doesn't amend once logged in, and it stops all PHP after it on the page from working.

Just so you know, this is in an includes file in public_html/includes/{file}. The forum is in public_html/forum/.

<?php
chdir('./forum/');
define("IN_MYBB", 1);
require './global.php';
?>
<div class="moduletop">Recommended Links</div>
 <div class="menu">
<?php

if($mybb->user['uid'])
{
echo "Hey, $mybbuser[username].<br>
Thanks for logging in.";
}
else
{
echo "<form action='forum/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>";
}
?>
 </div>
<div class="modulebottom"></div>
hi!!

I used this and it is very useful but I have a problem. I use a cms (xoops) and I had to did an iframe with that login. Well, the file where is that code is in loggin.php but I didn't use login form just a link to login form in forums. When I log in I'm redirecting to loggin.php and I want that it goes to forum index. How can I do it?

thx
(2009-01-08, 01:40 PM)utenfly Wrote: [ -> ]hi!!

I used this and it is very useful but I have a problem. I use a cms (xoops) and I had to did an iframe with that login. Well, the file where is that code is in loggin.php but I didn't use login form just a link to login form in forums. When I log in I'm redirecting to loggin.php and I want that it goes to forum index. How can I do it?

thx

Heya!

In order to force redirection to the forum index you have to change this:
<input type='hidden' name='url' value='index.php' />
to have "value='index.php'" instead of anything else.
Ya.. well, I don't use the way of first post. I changed the form by a "Enter - Register".
The original tutorial seems to work perfectly in Firefox when you leave the cookie domain blank and path as only ' / ' instead of ' /bb/ '

but...

Those same settings leave IE unable to logout.


??????????

I haven't read the entire thread.
Can someone please, post the full code for a login which actually works, or...
Does it work at all???


########
EDIT:

I got the original code (with standard cookie settings and file paths need to be edited) to work in both IE and Firefox. Wink

The catch:
If you make a "custom" .php page and place it in the root MyBB folder, then (of course) the cookies work fine in IE.

########

Anyone know how to make this actually work in a home directory when MyBB is in a sub-folder?
make your:
for instance:
  Board URL: yourwebsite.com/mybb 
  Homepage URL: / (so just yourwebsite.com)
set these settings:
  cookie domain: .yourwebsite.com
  Cookie Path: empty

With those settings it should work.

in the pages where the login has to be checked:
chdir('./mybb/');
define("IN_MYBB", 1);
require './global.php';
Whats the best method when using 1.4?
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