Help: How to create a members restricted page ??

This is an archive of the phpBB 2.0.x support forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785
Locked
cabaz777
Registered User
Posts: 20
Joined: Sat Feb 12, 2005 6:13 am

Help: How to create a members restricted page ??

Post by cabaz777 »

Hi all,

I want to create a standalone php page that is only accessible if the visitor is logged in my phpbb board.

For example I have my forum as www.domain.com/forum and I want to create a page called example.php with the following path:
www.domain.com/forum/example.php

What I want for this example.php page is to load only if the visitors is registered and logged, and if not to send the user to the login screen, exactly as phpbb do when trying to view a page configured to be read for members only.

Im almost sure I need to add this new page a "include" or a code that is already in the phpbb files (which checks the user as signed in), but dont know which one.


Thanks in advance
rødøye
Registered User
Posts: 9
Joined: Sat Feb 12, 2005 6:31 pm

Post by rødøye »

when you logg in to phpBB, some session variables are set. You can simply set an if() statement and se if users are logged in. exampel

Code: Select all

session_start()
if (session['logged_in'] == TURE) 
{
//the page
}
else
{
header ('location: http://www.YOURDOMAIN.COM/PHP'slogginpage');
}
Jeg kom, jeg så, og jeg gikk igjen (Cæsar)
Norwegian support: phpbb.no
I appologise for my bad English, and hope you understand me!
cabaz777
Registered User
Posts: 20
Joined: Sat Feb 12, 2005 6:13 am

Post by cabaz777 »

thanks for your help, but im stupid with php :oops:

i did this:

Code: Select all

<?php
session_start() 
if (session['logged_in'] == TRUE) 
{ 
<br>my html code goes here, blah, blah
} 
else 
{ 
header ('location: http://www.domain.com/forum/login.php'); 
} 
?>
but im getting a
Parse error: parse error, unexpected T_IF in /data/httpd/vhosts/domain.com/httpdocs/forum/test.php on line 3

Yes, i know . i must learn php :oops:
Poupoune
Former Team Member
Posts: 702
Joined: Sun Apr 18, 2004 4:04 pm
Location: In the stars... where you left me, and where I will wait for you... always...
Contact:

Post by Poupoune »

Poupoune - http://www.poup.net
My styles : [ La courbe de tes yeux ] - [ Stars are for dying ] - [ Plenitude ] - [ genElectro ]
skeezmo
Registered User
Posts: 9
Joined: Sat Dec 18, 2004 8:18 pm

Post by skeezmo »

you need to put all html in an echo statement:
For example:

Code: Select all

<?php
session_start()
if (session['logged_in'] == TRUE)
{
echo 'Skeez is overly sexy!';
}
else
{
header ('location: http://www.domain.com/forum/login.php');
}
?> 
cabaz777
Registered User
Posts: 20
Joined: Sat Feb 12, 2005 6:13 am

Post by cabaz777 »

Poupoune wrote: Take a look at this tutorial > http://www.phpbb.com/kb/article.php?article_id=143 :wink: .


not only i need to learn php, i also need to browse the tutorials before asking. :oops:

thanks poupoune, that´s what i was looking for.
Locked

Return to “2.0.x Support Forum”