Sarky Posted April 10, 2007 Share Posted April 10, 2007 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 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 More sharing options...
monk.e.boy Posted April 10, 2007 Share Posted April 10, 2007 You would be better off asking this on the BBphp forum. But I expect there is a template that has an 'if logged in {} else {}' somewhere. monk.e.boy Link to comment https://forums.phpfreaks.com/topic/46440-linking-forum-with-main-website/#findComment-225902 Share on other sites More sharing options...
maxic0 Posted April 10, 2007 Share Posted April 10, 2007 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. Link to comment https://forums.phpfreaks.com/topic/46440-linking-forum-with-main-website/#findComment-225913 Share on other sites More sharing options...
Sarky Posted April 10, 2007 Author Share Posted April 10, 2007 Thanks monk.e.boy = i asked on the phpbb site and my post got deleted! lol 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 Link to comment https://forums.phpfreaks.com/topic/46440-linking-forum-with-main-website/#findComment-225943 Share on other sites More sharing options...
maxic0 Posted April 10, 2007 Share Posted April 10, 2007 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! Link to comment https://forums.phpfreaks.com/topic/46440-linking-forum-with-main-website/#findComment-225953 Share on other sites More sharing options...
Sarky Posted April 10, 2007 Author Share Posted April 10, 2007 Thanks again maxic0 I get you on msn later to annoy you with more Questions! lol Link to comment https://forums.phpfreaks.com/topic/46440-linking-forum-with-main-website/#findComment-225967 Share on other sites More sharing options...
maxic0 Posted April 10, 2007 Share Posted April 10, 2007 lol tis cool my friend! Link to comment https://forums.phpfreaks.com/topic/46440-linking-forum-with-main-website/#findComment-225970 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.