PDA

View Full Version : Write a Forum from Scratch!



klange
July 11th, 2009, 01:25 PM
Hey, you read this: I had completely forgotten about this thing, I'll do it this week (not now, it's late >_>) okay?

Introduction
Alright, so, I felt I'd write a tutorial on how to write a discussion forum from scratch. I'm going to do this in multiple installments, so bear with me. I'll only go into the "what you need" for today, and then move into the basics tomorrow. Hopefully by next Tuesday this tutorial will be done...

Tools Required
- PHP 5
- Apache or similar (I'm not going to show you how to set it up)
- MySQL
- MySQL GUI Tools or similar package (I like the cross-platform Administrator and Query Browser, good solid tools, and I'll be using them in my examples)
- Notepad++, Gedit, or other similar editor

If you're not up to the task of setting this stuff up and don't have your own hosting somewhere, you can get a package like XAMPP (http://www.apachefriends.org/en/xampp.html). It's easy to set up on Windows and Linux and provides a simple interface to get your server running with everything you need.

Structure of this Tutorial
We'll first explore the basic design of a simple forum and look at the aspects we want to replicate. We'll then cover the basics of our MySQL table structures and how they will work in our code. Then we'll get to work on the actual coding in PHP. Finally, we'll style the forum with some CSS. Our final product will be a flat forum with user accounts, including avatars, signatures and bbCode.

Part I: Forum Basics
Let's look at the forum we're on now: vBulletin is primarily a flat-thread forum with categories, boards and threads - the same model we'll be using. This has remained the dominant layout for community forums for years. The other layout you tend to find is nested tree replies, but it's very complicated and we won't get into it.

Category
_Board
__Thread
___Post
___Post
__Thread
___Post
___Post
_Board
__Thread
___Post
___Post
__Thread
___Post
___Post
Category
_Board
__Thread
___Post
___Post

Part II: SQL Tables
SQL is the basis for data storage on the Internet. Forums, CMSes, blogs - they all store data, and most all of them do it with SQL. There are a few different forms of SQL: MySQL, MSSQL, PL/SQL, etc., but MySQL is the most popular, mostly because it is free and open-source.

Our SQL is fairly simple, and you'll want to get your editor ready and make these now:
categories
id (int, primary key, auto-increment)
name (string)
boards
id (int, primary key, auto-increment)
name (string)
perms (int, default=0, not-null)
threads
id (int, primary key, auto-increment)
title (string)
author (int, not-null)
content (TEXT)
posts
id (...)
author (int, no-null)
content (TEXT)
users
id (...)
name (string)
level (int, default=0, not-null)
signature (string)
avatar (string)

(I'll put up SQL that generates these tomorrow; the rest of the tutorial should be up later today)

Evil_Monkey
July 11th, 2009, 02:46 PM
Cool, looking forward to seeing this.

klange
July 14th, 2009, 01:05 AM
Oops, I wss supposed to start this on monday... I'll do it "today" I guess.

English Mobster
July 14th, 2009, 04:42 AM
This sounds really interesting. I'll be looking forward to seeing this!

Kalub
August 2nd, 2009, 09:52 PM
Requesting Update

klange
August 2nd, 2009, 09:53 PM
Requesting Update
I completely forgot about this :gonk: I'll write it this week, I've got more time to do the Cerebrum things I needed to do, so it should be fine.

TheGhost
August 3rd, 2009, 01:27 AM
Do it in EJB 3.0 and I'll give it a read ;p

jk I'm still interested in reading this

legionaire45
August 5th, 2009, 03:12 AM
Same, considering I'm working through learning (http://devzone.zend.com/node/view/id/627) PHP and MySQL right now :).

klange
August 5th, 2009, 12:18 PM
Don't worry guys, I'm working on the tutorial, but don't want to post it until it's done.

Dwood
August 12th, 2009, 12:08 PM
Don't worry guys, I'm working on the tutorial, but don't want to post it until it's done.


:maddowns:

klange
August 12th, 2009, 12:20 PM
:maddowns:
And certain things pushed me back further :v:

Don't worry, I'll finish it... eventually...

English Mobster
October 7th, 2009, 06:20 PM
What happened to this?

klange
October 7th, 2009, 06:29 PM
What happened to this?
I'm working on it. I have a very busy schedule these days. :nsmug:

n00b1n8R
November 9th, 2009, 02:45 AM
HEY KLANGE HOW DO I MADE FORUMZ???

klange
November 10th, 2009, 05:58 PM
HEY KLANGE HOW DO I MADE FORUMZ???


Fuck this, I can't finish it. :( :( :( :(


Download phpBB and install it~~

Dwood
November 10th, 2009, 06:12 PM
this, I can't finish it. :( :( :( :(


Download phpBB and install it~~



SOMEONE BAN THIS PERSON THEY DO NOT QUALIFY TO BE MEMBER.

klange
November 10th, 2009, 06:47 PM
I'z gonna finish it some day.

Maybe when I'm at home November 21~29. That's the perfect time!

Con
November 14th, 2009, 01:05 AM
hey stop posting in here
locked until shit happens