2013-05-06, 01:27 AM
Hello every one. I am going to show you how to import a "Your Profile" button. First off you will need to import all the stuff like if you where to make a login system with it.
This should go at the complete top of the website.
Then I remembered about the . *this is AND in PHP* so I sat there and it took me about 10 minutes because well, i'm not good with PHP.
I came up with a end result of:
The end product:
This should go at the complete top of the website.
<?php
chdir('forums/'); // path to MyBB
define("IN_MYBB", 1);
require './global.php';
?>
Next we want to add this where we want the login system to be.if($mybb->user['uid'])
{
// The user is logged in, say Hi
echo "Hey, " . $mybb->user['username'] . "!";
?>
<?php echo"<a href='forums/member.php?action=profile&uid=" . $mybb->user['uid']; echo "'>";?> You're Profile
<?php
}
else
{
// The user is not logged in, Display the form
echo "<form action='forums/member.php' method='post'>
Username: <br><input type='text' name='username' size='25' maxlength='30' /><br />
Password: <br><input type='password' name='password' size='25' /><br>
<input type='hidden' name='action' value='do_login'>
<br>
<input type='hidden' name='url' value='/' />
<input type='submit' class='submit' name='submit' value='Login' /></form><br>";
}
?>
Now doing a bit of investigation with the forums i noticed the the profile link is classified using the UID. UID is User ID. You will have 1-how many users have registered on your website. You *being the admin and first person to sign up on the website* should be 1. But we can't just do something like:<?php echo"<a href='forums/member.php?action=profile&uid=1";?> You're Profile ?>
This would bring you only to your profile. We want it to bring it to the user's profile. If wanted, we can come up with a idea, or create a bootstrap. These can be complicated just to get to a users profile. So I sat there and though. How can I do this without taking to much time?Then I remembered about the . *this is AND in PHP* so I sat there and it took me about 10 minutes because well, i'm not good with PHP.
I came up with a end result of:
<?php echo"<a href='forums/member.php?action=profile&uid=" . $mybb->user['uid']; echo "'>";?> You're Profile
I felt really stupid not thinking of this. but I decided to make this to save you guys time. Thanks The end product:
<?php
chdir('forums/'); // path to MyBB
define("IN_MYBB", 1);
require './global.php';
?>
if($mybb->user['uid'])
{
// The user is logged in, say Hi
echo "Hey, " . $mybb->user['username'] . "!";
?>
<br>
<?php echo"<a href='forums/member.php?action=profile&uid=" . $mybb->user['uid']; echo "'>";?> You're Profile<br>
<a href='forums/member.php?action=logout&logoutkey=5b55442536a4d92a97ff3d98ce49825b'>Logout</a>
<?php
}
else
{
// The user is not logged in, Display the form
echo "<form action='forums/member.php' method='post'>
Username: <br><input type='text' name='username' size='25' maxlength='30' /><br />
Password: <br><input type='password' name='password' size='25' /><br>
<input type='hidden' name='action' value='do_login'>
<br>
<input type='hidden' name='url' value='/' />
<input type='submit' class='submit' name='submit' value='Login' /></form><br>";
}
?>
</div>