MyBB Community Forums

Full Version: Login box on Home page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Good morning. I have spent most of my night trying to add the login and password box into my home page. I was wondering how I go about adding this so useres can login and after they login, the code can welcome them. I need the sign in functions of the portal.php and for it to get if a user is online. I could realy use some help with this I have been fidling with the portal page but still no luck in adding it on my homepage. I don't have a link to my site because the site is still on my test server.
on your homepage, just do this:
<?php
include("folder_with_mybb/portal.php");
?>

i think...
I need just the login box with out templates.
Quote:<div align="center">
<form action="forums/member.php" method="post">
<table cellspacing="0" cellpadding="0" border="0" width="65%" align="center">
<tr><td class="tborder">
<table border="0" cellspacing="1" cellpadding="4" width="100%">
<tr>
<td class="thead" colspan="2"><strong>Login: Forums</strong></td>
</tr>
<tr>
<td class="trow1"><strong>Username:</strong></td>

<td class="trow1"><input type="text" name="username" size="25" maxlength="25"></td>
</tr>
<tr>
<td class="trow2"><strong>Password:</strong><br /><span class="smalltext">Please note that passwords are case sensitive.</span></td>
<td class="trow2"><input type="password" name="password" size="25" maxlength="15"> (<a href="FORUM FOLDER/member.php?action=lostpw">Lost your password?</a>)(<a href="FORUM FOLDER/member.php?action=register">Register</a>)</br>
<input type="submit" name="submit" value="Login"></td>
</tr>
</table>
</td></tr></table>
<br/>

<input type="hidden" name="action" value="do_login">
<input type="hidden" name="url" value="FORUM FOLDER/index.php" />
</form>
</div>
Replace FORUM FOLDER with your forum's foler, duh.
Thanks z3rb works perfectly! Is there any way I could put a IF statment in there so if the user is login in it will get the user name and welcome them or if there not loged in then it will put the login box?
Save your file as a .php (ie. test.php)

<?php
require "./forum/global.php";

echo "<div align=\"center\">
<form action=\"forums/member.php\" method=\"post\">
<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"65%\" align=\"center\">
<tr><td class=\"tborder\">
<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" width=\"100%\">
<tr>
<td class=\"thead\" colspan=\"2\"><strong>Login: Forums</strong></td>
</tr>
<tr>";
if($mybb->user['guest'])
{
echo "<td class=\"trow1\"><strong>Username:</strong></td>

<td class=\"trow1\"><input type=\"text\" name=\"username\" size=\"25\" maxlength=\"25\"></td>
</tr>
<tr>
<td class=\"trow2\"><strong>Password:</strong><br /><span class=\"smalltext\">Please note that passwords are case sensitive.</span></td>
<td class=\"trow2\"><input type=\"password\" name=\"password\" size=\"25\" maxlength=\"15\"> (<a href=\"FORUM FOLDER/member.php?action=lostpw\">Lost your password?</a> (<a href=\"FORUM FOLDER/member.php?action=register\">Register</a> </br>
<input type=\"submit\" name=\"submit\" value=\"Login\"></td>";
} else {
echo "<td class=\"trow1\">Your Text Here</td>";
}
echo "</tr>
</table>
</td></tr></table>
<br/>

<input type=\"hidden\" name=\"action\" value=\"do_login\">
<input type=\"hidden\" name=\"url\" value=\"FORUM FOLDER/index.php\" />
</form>
</div>";

?>


I don't know if that if statement is right but you get the idea.
i keep getting
Warning: main(./inc/init.php) [function.main]: failed to open stream: No such file or directory in C:\xampp\htdocs\blake\mybb\global.php on line 12

Fatal error: main() [function.require]: Failed opening required './inc/init.php' (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\blake\mybb\global.php on line 12

I even striped down the code to

require "./mybb/global.php";


if($mybb->user['guest'])
{
echo  "yes";
} else {
echo "no";
}

How do I fix the init.php file error?