phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

Login on home page?


 
Search this topic... | Search General Support... | Search Box
Register or Login to Post    Index » General Support  Previous TopicPrint TopicNext Topic
Author Message
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: 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:&nbsp;
<input type="text" class="post" name="username" size="8" maxlength="40" value="" />
<img src="/graphics/template_imgs/spacer.png" width="8" height="1" />
Password:&nbsp;
<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: 414
Location: Québec


flag
PostPosted: 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



PostPosted: 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: 414
Location: Québec


flag
PostPosted: 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



PostPosted: 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


flag
PostPosted: 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
Display posts from previous:   
Register or Login to Post    Index » General Support  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0108 seconds using 15 queries. (SQL 0.0022 Parse 0.0005 Other 0.0081)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo