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
Anyone have an answer for this? It's been a while and was lost in the thread.

(2008-12-15, 09:57 PM)tbanucci Wrote: [ -> ]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...
Very fine thankz
Could I get some help with this? I added another page to my MyBB install,
http://www.x-ind.com

Should give you the homepage. But, the login box (welcomebox) does not show a user as logged in. It just constantly shows the login form no matter what. I was wondering if that is fixable. The MyBB installation is found at http://www.x-ind.com/board
Ok this is what I have:
<?php
chdir('forum'); // path to MyBB
define("IN_MYBB", 1);
require './global.php';
?>
<?php
include("header.php");
?>
<?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='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>";
}
?>
<?php
include("footer.php");
?>
When I do this and login. The form is still there and not the logged in message. Any clue of why this is happening?
^^^ Is there something I am missing maybe?
Does anyone Know? ^^^^^
<?php
chdir('mybb'); // path to MyBB
define("IN_MYBB", 1);
require './global.php';
?>

<?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='mybb/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>";
}
?>
I have that in a PHP file and when I browse to it, it is just a blank page. I tried this code in a HTML page:
<html>
<title>MyBB Login Page</title>
<body>
<?php
chdir('mybb'); // path to MyBB
define("IN_MYBB", 1);
require './global.php';
?>

<?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='mybb/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>";
}
?>


</body>
</html>

The text area's show up but there is some of the code showing up. See the picture attached. I would like to know how to fix this in the HTML page and the PHP page.
THe files need to be PHP not html!
(2009-04-21, 09:34 PM)No0oB Wrote: [ -> ]THe files need to be PHP not html!

If you read what I posted, I tried this code in a PHP file and I get a blank page!
<?php
chdir('mybb'); // path to MyBB
define("IN_MYBB", 1);
require './global.php';
?>

<?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='mybb/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>";
}
?>
I'm not that much of an IDIOT!
??// remove the ??
Thanks.
My forum is in a sub-domain, so what do I need to put into the chdir part ?

I have tried using ('http://www.co.......
and just ('www.co.....

but no luck
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