Skip to main content
GameDev.net gamedev.net
🔒 Locked

[web] making a user account system?

Started by EarthwormJim May 4, 2008 at 3:44 PM 3 replies 1.5k views
Original Post
EarthwormJim
EarthwormJim
I need serious help or at least a point in the right direction. I haven't been able to find any good guides! I would like to make a user account system that is tied to a forum. The user can register an account, the account would allow dynamic features on the website and would allow the user to post on the forum. Pretty much the model of any community based website. I would prefer a free forum, like PHPbb, but if I have to I'll buy a license for vBulletin. Either way, it'll take some modding. I have no idea how to do this; I made a registration page that enters information into a MySQL database before I started to think about things, but thats as far as I got. Many many thanks to whoever helps me sort this out! I at least need some direction.
Sander
Sander
It really depends on which forum software you want to use. My advice: pick a forum, install it and then ask on the support forum for the software you chose for more information.

I know that there are several mods for phpBB 2.x that would allow you to do this with minimal hacking. I have no idea if the same mods have been made for phpBB 3.x or the other forums out there. Most likely there have.
jamessharpe
jamessharpe
You could try out drupal for the user management side of things and integrate it with phpBB using http://drupal.org/project/phpbb. Drupal does have its own forum software too, but its very simple.
CaspianB
CaspianB
I had a website awhile back where I used phpBB 2.0 and tied into the phpBB login/user system. If you want something simple, then you can have the users register for the forum, then create your own table based with a primary key linked to the phpBB user_id key for storing whatever data you need for your own purposes. I'm not certain if this is what you're looking for or not, but here's the code regardless.

The code to validate the login information and start the session for phpBB 2.0 is extremely easy. I'm not certain about phpBB 3.0, but I *think* they may have some form of an API that makes it easy to check session data as well.

For registration, I just redirected to the phpBB registration system and let it handle everything. There's a few things it had to do besides just inserting into the users table, and I considered it more trouble than it was worth to recreate my own registration code.

Anyway, here's my code for starting a phpbb 2.0 session (if you choose to write your own login form on your website in addition to the phpbb login forms).

session_start();/* *********************************************** */// This is the portion that lets you tie into the phpbb// sessions.// phpBB includesdefine('IN_PHPBB', true);// Physical path to forums root : CUSTOMIZE$phpbb_root_path = './phpbb/';require_once($phpbb_root_path . 'extension.inc');require_once($phpbb_root_path . 'common.'.$phpEx);/* *********************************************** */// $_POST['username'] and $_POST['password'] obviously come from a form submission$username = ( isset($_POST['username']) ) ? phpbb_clean_username($_POST['username']) : '';$password = ( isset($_POST['password']) ) ? $_POST['password'] : '';$sql_query = sprintf("SELECT * FROM `%s` WHERE username = '%s' AND user_password = '%s'", USERS_TABLE, $username, $password);$query_users = mysql_query($sql_query, $dblink) or die(mysql_error());$row_user = mysql_fetch_assoc($query_users);if ( $row_user ){   session_begin($row_user['user_id'], $user_ip, PAGE_INDEX, 0, TRUE);   header("Location: index.php");   die('Login successful.');}else{   $loginError = "The username or password you specified was incorrect.";}// And here is the code you call to logout / end the sessionif ( $userdata['session_logged_in'] ){   session_end($userdata['session_id'], $userdata['user_id']);   session_destroy();}header("Location: index.php");die('Logout successful.');



And here's the code for checking who is logged in.
session_start();// phpBB includesdefine('IN_PHPBB', true);// Physical path to forums root : CUSTOMIZE$phpbb_root_path = './phpbb/';require_once($phpbb_root_path . 'extension.inc');require_once($phpbb_root_path . 'common.'.$phpEx);// Start phpbb session$userdata = session_pagestart($user_ip, PAGE_INDEX);// initialize the $userdata array with the proper valuesinit_userprefs($userdata);



The $userdata array will be populated with all data in the phpbb_users table that is currently logged into that session. I stick that information into a simple .php file that I include on every page on my main website. I also wrote my own login form and showed you the code for that, but if you wish you can always just redirect them to the forums to perform the log in.

As I said, this is for phpBB 2.0. phpBB 3.0 will likely be different. And perhaps even easier.
EarthwormJim
EarthwormJim
Quote:
Original post by CaspianB
I had a website awhile back where I used phpBB 2.0 and tied into the phpBB login/user system. If you want something simple, then you can have the users register for the forum, then create your own table based with a primary key linked to the phpBB user_id key for storing whatever data you need for your own purposes. I'm not certain if this is what you're looking for or not, but here's the code regardless.

The code to validate the login information and start the session for phpBB 2.0 is extremely easy. I'm not certain about phpBB 3.0, but I *think* they may have some form of an API that makes it easy to check session data as well.

For registration, I just redirected to the phpBB registration system and let it handle everything. There's a few things it had to do besides just inserting into the users table, and I considered it more trouble than it was worth to recreate my own registration code.

Anyway, here's my code for starting a phpbb 2.0 session (if you choose to write your own login form on your website in addition to the phpbb login forms).

*** Source Snippet Removed ***


And here's the code for checking who is logged in.
*** Source Snippet Removed ***


The $userdata array will be populated with all data in the phpbb_users table that is currently logged into that session. I stick that information into a simple .php file that I include on every page on my main website. I also wrote my own login form and showed you the code for that, but if you wish you can always just redirect them to the forums to perform the log in.

As I said, this is for phpBB 2.0. phpBB 3.0 will likely be different. And perhaps even easier.


Wow, thanks!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.