Author |
Message |
Acaria Board Member

Joined: 20 Feb 2009
         Posts: 238

|
Posted: Sun Feb 28, 2010 9:53 am Post subject: Login on home page? |
|
|
Okay, so I've been working on a home page for my site. It's not in the PhpBB2 direction, simply at root/home.php. I want it to have a small login section at the top and then take you back to the homepage where your avatar and stats appear.
I know I need to use the logged in and out switches for this, but they don't work here. First off, here's what I'm using to log in:
Code: | <form action="/forums/login.php" method="post" target="_top">
Username:
<input type="text" class="post" name="username" size="8" maxlength="40" value="" />
<img src="/graphics/template_imgs/spacer.png" width="8" height="1" />
Password:
<input type="password" class="post" name="password" size="8" maxlength="32" />
<img src="/graphics/template_imgs/spacer.png" width="3" height="1" />
<input type="checkbox" name="autologin" />
<input type="hidden" name="redirect" value="" />
<img src="/graphics/template_imgs/spacer.png" width="3" height="1" />
<input type="submit" name="login" class="mainoption" value="Log in" />
</form> |
Now that works just fine and does just what I want. So now all I need to do is get it to where when the user is logged in and goes back to the home page, the switches work. I tried adding this to the top of my page:
Code: | <?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
?> |
However, it does nothing. So... I'm stuck. I remember seeing some kind of assign_vars or other thing that assigned the switch variables (don't remember the name of the function), but couldn't find it.
So does anyone know how I can get the switches to work on my page? |
|
Back to top |
|
 |
Salvatos Board Member

Joined: 19 Feb 2009
         Posts: 415 Location: Québec

|
Posted: Sun Feb 28, 2010 6:04 pm Post subject: Re: Login on home page? |
|
|
If your page is in root/, and your forum in root/phpBB2/, you need to change this:
Code: | $phpbb_root_path = '/phpBB2/'; |
I also remember having to mess around a bit with templates, but let's first see what you get with this. |
|
Back to top |
|
 |
Acaria Board Member

Joined: 20 Feb 2009
         Posts: 238

|
Posted: Sun Feb 28, 2010 7:14 pm Post subject: Re: Login on home page? |
|
|
Doesn't work. ): |
|
Back to top |
|
 |
Salvatos Board Member

Joined: 19 Feb 2009
         Posts: 415 Location: Québec

|
Posted: Sun Feb 28, 2010 7:14 pm Post subject: Re: Login on home page? |
|
|
What is the output? |
|
Back to top |
|
 |
Acaria Board Member

Joined: 20 Feb 2009
         Posts: 238

|
Posted: Tue Mar 23, 2010 12:20 am Post subject: Re: Login on home page? |
|
|
Not sure what you mean, Salvatos. It's not outputting anything. I can log in perfectly fine, I'm just unsure as to how to check if they are logged in or not.
My guess is that I just need to check for the logged-in cookie/session and if it exists, show one thing. If it doesn't, another.
I just don't know what that cookie/session is entitled. Once I find that, would this code work?
Code: |
if (isset($_COOKIE['logged_in_cookie_name']))
{
blah blah blah code
}
else
{
login thing
}
|
|
|
Back to top |
|
 |
Murmur Board Member

Joined: 20 Aug 2009
        Posts: 57 Location: California

|
Posted: Wed Mar 24, 2010 5:08 am Post subject: Re: Login on home page? |
|
|
I believe what you need to do - if you haven't already - is to establish a proper phpBB session in your external page.
Code: | <?php
define('IN_PHPBB', true);
$phpbb_root_path = 'MyPathTophpBBroot';
$phpEx = "php";
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
// now a phpBB session is established for this page run and....
// we have access to some phpBB facilities and variables
if( $userdata['session_logged_in'] )
{
echo "Welcome " . $userdata['username'];
}
else
{
echo "You are Anonymous - please register or login.";
}
?>
|
_________________ ComBoa - phpBB 2 Lives! |
|
Back to top |
|
 |
|