Jump to content

Linking forum with main website


Sarky

Recommended Posts

Hi guys, I noticed that your website was at the top of a google search so I joined up to ask a question.

 

Take a look at this image:

http://img235.imageshack.us/img235/6923/phpqml8.jpg

phpqml8.th.jpg

 

 

 

What i would be asking is this...

 

How do I make it so that visitors MUST be logged in to my phpBB2 forum before the lines "Hello hehehehehehehhe" will be visable?

 

And when visitors are NOT logged into the phpBB forum, they simply get a "you must login to the forum to see this page"

 

?

 

Thanks for all and any help in advance.

 

 

Link to comment
https://forums.phpfreaks.com/topic/46440-linking-forum-with-main-website/
Share on other sites

You have to put this at the top of your page..

 

<?php

define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.' . $phpEx);
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);

?>

 

You have to make sure that the value of the $phpbb_root_path variable contains the path to your forum folder.

 

Once doing this all the information about the user that is logged in will be stored in the $userdata variable.

 

To display their information you would have to put eg.

 

<?php

echo $userdata['username'];

?>

 

 

To see if someone is logged in you can simply do this..

 

<?php

define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.' . $phpEx);
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);

if ($userdata['username'] == "Anonymous") {


echo "You Are Not Logged In!";

}else{

echo "Welcome ";
echo $userdata['username'];

?>

 

 

I set the IF statement to see if the users name is Anonymous because if the user is not logged in, $userdata['username'] is set to Anonymous.

 

Hope this helps.

 

Thanks monk.e.boy = i asked on the phpbb site and my post got deleted! lol  :o

 

Thanks kindly also maxic0

 

--

 

maxic0:

 

Is there anyway I can use a "if the user is logged in, display the page" and "if the user is not logged in, do not display the page" tag ?

 

I am basically making a (long) form and would like users to be registered (and logged in) before they can complete and submlit the form for security and abuse prevention.

 

Would also like their registered username, email address and IP address printed on the form for them to see on a readonly basis!

 

Thanks again for all help and advice, that code you posted worked a treat

 

 

You can see all the fields that you might want to show on your page.. You can see them all by doin this..

 

<?php

define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.' . $phpEx);
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);

while (list ($value, $key) = each ($userdata)) {
  
  echo $value;
  echo " ";
  echo $key;
  echo "</BR>";
  
  
}

?>

 

So if you want to show their email then you can do this..

 

 

<?php

echo $userdata['user_viewemail'];

?>

 

 

 

If you wanted to show a page then you can do this..

 

<?php

if ($userdata['username'] != "Anonymous") {

include ('page.php');

}else{

echo "You Must Be Logged In To View This Page!";

}

?>

 

 

Hope this helps!  :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.