hi guys,
I want to create my own PHP, MySQL forum for my website. Please can anybody give me or direct me to a website where I could get the source code.
Thanking you in advance
hi guys,
I want to create my own PHP, MySQL forum for my website. Please can anybody give me or direct me to a website where I could get the source code.
Thanking you in advance
For a practical, learning-first start: this builds on the suggestions from , and by giving a compact, hands‑on base you can extend. Below is a minimal schema (users/forums/threads/posts), a tiny PDO-based register/login example, and a short checklist of concrete things to implement or watch for as you grow the project.
CREATE TABLE users (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL UNIQUE,
email VARCHAR(255) NOT NULL UNIQUE,
password_hash VARCHAR(255) NOT NULL,
role ENUM('user','mod','admin') NOT NULL DEFAULT 'user',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE forums (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(150) NOT NULL,
parent_id INT UNSIGNED DEFAULT NULL,
position INT DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE threads (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
forum_id INT UNSIGNED NOT NULL,
user_id INT UNSIGNED NOT NULL,
title VARCHAR(255) NOT NULL,
slug VARCHAR(255) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
INDEX (forum_id), INDEX (user_id), INDEX (slug)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE posts (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
thread_id INT UNSIGNED NOT NULL,
user_id INT UNSIGNED NOT NULL,
content MEDIUMTEXT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
is_deleted TINYINT(1) NOT NULL DEFAULT 0,
INDEX (thread_id), INDEX (user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; // minimal examples (assumes $pdo is a configured PDO)
function register($pdo,$u,$e,$p){
$hash = password_hash($p, PASSWORD_DEFAULT);
$stmt = $pdo->prepare("INSERT INTO users (username,email,password_hash) VALUES (?,?,?)");
return $stmt->execute([$u,$e,$hash]);
}
function login($pdo,$email,$password){
$stmt = $pdo->prepare("SELECT id,password_hash FROM users WHERE email = ?");
$stmt->execute([$email]); $user = $stmt->fetch(PDO::FETCH_ASSOC);
if($user && password_verify($password,$user['password_hash'])){
session_regenerate_id(true);
$_SESSION['user_id']=$user['id'];
return true;
}
return false;
} Practical checklist and cautions:
This gives a small, safe base to start from; harden incrementally and add tests for auth, permissions and input handling as you go.
Jump to Post— Will Gresham 81Surely if you are creating your own then you will write the source code your self...
Or do you mean you want an open source one?
Try:
or
phpBB
Surely if you are creating your own then you will write the source code your self...
Or do you mean you want an open source one?
Try:
or
phpBB
Yes I want to create my own. But i just want sample code so that I develop mine from there!
you need decide the navigation of your forum site, then the code need to develop that forum will available on the internet individually...you just start it,if any codes requires ,post here,many daniweb code gurus will help you...And mind one thing , develop it by SEO friendly..And follow some security instuctions...
All the best...
Shanti.
A forum differs slightly from a custom CMS or a social networking site. The threads and posts can be viewed like the news on a backend. The most important points to get focus are: 1) the ACL or authentication part taking into account the moderators and users, as well as registration and ban process. 2) URL Rewriting, convert thread titles to SEO ones. 3) A parser to interpret BBCode tags on the input. Also the input window can be ornamented with Javascript or using a WYSIWIG editor like FCKeditor or TinyMCE with disabled features to make it very similar to vBulletin editor showed on this site.
For learning purposes (I like pretty much phpBB but seems very entangled) I suggest to start with SMF forum from simplemachines, it's free and open source too. The code, in special about polling features are very clear.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.