Integrating MyBB into your website. (Login Form)
#1
Hmmm... Let me guess.
You need to integrate your forum within your website?
Well, you came to the right place.

What you need
1. Basic Knowledge In HTML.
2. Basic Knowledge In PHP.
3. MyBB (Duh).
4. A website to integrate it with.

How To
First, Before ANYTHING, even the "<HTML>" or "<?" Tag, place this.
<?php
chdir('forums'); // path to MyBB
define("IN_MYBB", 1);
require './global.php';
?>
Then, place this where you want the login form/welcome message to appear.
<?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>";
}
?>

Where 'index.php' from line 17 (or close):
<input type='hidden' name='url' value='index.php' />
Should be replaced with where you want to redirect after the login.

And Where 'forums/member.php' from line 12 (or close):
<form action='forums/member.php' method='post'>
Is the Path to your forum's member.php. Generally "forums/member.php".

If you need to add anything under on line 7 (or close):
echo "Hey, $mybbuser[username].<br>
Thanks for logging in.";

Make it like:
echo "Hey, $mybbuser[username].<br>
Thanks for logging in.<br>Your text here.";

To Add a link, do not use.

<a title="link Description" href="http://link/link.php">Link</a>
But
<a title='link Description' href='http://link/link.php'>Link</a>

In other words, Do NOT use double quotes inside
echo ""
.
Use 's instead of "s.

Also, save the file (Which has the login form) as "something.php" and not "something.html" or "something.htm".

*link removed because it was broken - DennisTT*

Regards,
Marc
[Image: gzrsig.php]
Reply
#2
Nice tutorial Good jobWink
Reply
#3
Thanks.
[Image: gzrsig.php]
Reply
#4
Marc O' Connor Wrote:To Add a link, do not use.

<a title="link Description" href="http://link/link.php">Link</a>
But
<a title='link Description' href='http://link/link.php'>Link</a>

In other words, Do NOT use double quotes inside
echo ""
.
Use 's instead of "s.
If you wanna use double quotes(") you can do \" tho.
Reply
#5
I find it that members who are not very experienced with PHP would find a single quote easier.

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>";
Wouldn't look too welcoming, instead confusing to the PHP newcomers if you know what I mean.
[Image: gzrsig.php]
Reply
#6
I'm just saying for those who like double quotes Wink
Reply
#7
Ok.
Lol.
[Image: gzrsig.php]
Reply
#8
it better to use:
echo'<a title="link Description" href="http://link/link.php">Link</a>';
[Need Smilies? Get Me Smileys!
Reply
#9
No.
It isn't.
It is the exact same with just 's replaced with "s and vice versa.
[Image: gzrsig.php]
Reply
#10
or you could just use

?>
<a title="link Description" href="http://link/link.php">Link</a>
<?php

and not have to deal with any \'s
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)