Publishing System Settings Logout Login Register
PHPBB Usersystem Integration
TutorialCommentsThe AuthorReport Tutorial
Tutorial Avatar
Rating
Add to Favorites
Posted on October 10th, 2007
18942 views
PHP Coding
About this tutorial

This tutorial will teach you how to base a site around one of the best free forums out there "PHPBB". We will be basing it around the newest version PHPBB3. This tutorial does not work with older PHPBB versions.

Why I made this tutorial

When I began to make a site based around PHPBB I realised a serious lack of information on how to do it. So I have decided to make this tutorial in a hope it helps you guys if you ever want to make a site around PHPBB.


Lets Get Started!

Ok lets get started on this.

We need to download and install PHPBB in a directory. I would call the directory "forums". Once its installed we are ready to build the rest of the site.

Next we will get down to the actual coding.



Open up your PHP editing program. It does not matter the program you use it will make no difference to the outcome.

We are now going to create a file named config.php. You may rename it to whatever you want.

Config.php

 
<?php
define('IN_PHPBB', true); //Define IN_PHPBB
$phpbb_root_path = 'forums/'; //the path to where your forums are installed
$phpEx = substr(strrchr(__FILE__, '.'), 1); //The file extension
include($phpbb_root_path . 'common.' . $phpEx); //Include common.php from the forums directory

$user->session_begin(); //begin the user's session
$auth->acl($user->data); //Authenticate the user
?>


Config.php will need to be included on all pages.

Now we will create an index page.

Index.php


<?php
include('config.php'); //Include our config...
if($user->data['user_id'] != ANONYMOUS) //If the user isnt a guest
{
//It seems they are logged in. Put your content in here?
}
else
{
header('location:login.php'); //Hmm they ain't logged in. Redirect them!
}
?>


Now it seems we need a login page. So create a file named login.php

Login.php

 
<?php
include('config.php'); //Include our config...
if($user->data['user_id'] != ANONYMOUS) //If the user isnt a guest
{
echo 'You are already logged in.';
}
else //else they arent logged in ergo we show the login form. Juts basic HTML
{
?>
<form action="/forums/ucp.php?mode=login" method="post" enctype="multipart/form-data">
Username:
<input name="username" id="user" class="username" type="text" />
<br />Password:
<input name="password" id="pass" class="password" type="password" /><br />
Remember me? <input type="checkbox" name="autologin" id="autologin" style="width:14px;" /><br /><br />
<input type="hidden" name="redirect" value="/">
<input name="login" id="submit" value="Login" type="submit" />
</form>
<br /><br />
<a href="/forums/ucp.php?mode=register">Register?</a>
<?php
}
?>


More on the next page.



Ok there are probably a few more things you want to do. A logout link? Easy as pie:


<?php
include('config.php');
echo '<a href="'.append_sid($phpbb_root_path .'ucp.php?mode=logout&sid='.$user->session_id).'">Logout</a>';


And hey presto they are logged out!

What else could we do? How about show how many messages in your inbox!


<?php
include('config.php');
echo '<a href="/forums/ucp.php?i=pm&folder=inbox">('.
$user->data['user_unread_privmsg'].') Inbox';
?>


And there is plenty more things you can do with the right knowledge! Just try out things. You can always remove it if it doesnt work.

Any problems with this tutorial feel free to PM me here or Email mark@mark-cole.net

Thank you for reading

My website
Dig this tutorial?
Thank the author by sending him a few P2L credits!

Send
GTMedia

Hey Im a young webdeveloper from scotland. If you want to know more about me. Visit www.mark-cole.net :)
View Full Profile Add as Friend Send PM
Pixel2Life Home Advanced Search Search Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Pixel2life Homepage Submit a Tutorial Publish a Tutorial Join our Forums P2L Marketplace Advertise on P2L P2L Website Hosting Help and FAQ Topsites Link Exchange P2L RSS Feeds P2L Sitemap Contact Us Privacy Statement Legal P2L Facebook Fanpage Follow us on Twitter P2L Studios Portal P2L Website Hosting Back to Top