Home > Article > Backend Development > A simple PHP web forum
1. Need analysis
2. Solution
2.1 Forum design
2.2 Files used in Web forum applications
File name |
Type |
Description |
index.php |
App |
The home page that users see when entering the site. Includes an expandable and deletable list of all posts in the site |
new_post.php |
App |
Form to post new posts |
store_new_post.php | App |
Save posts entered into the new_post.phpform |
view_post.php |
App |
Show one post Individual articles and replies Its list of articles |
treenode_class.php |
Function library |
contains the node class that we will use to display the inheritance relationship of articles |
include_f ns.php |
Function Library |
Put together all other function libraries used in this program (other library type files are listed here) |
data_valid_fns.php |
Function Library |
Data inspection function |
db_fns.php |
Function library |
Database connection function |
discussion_fns.php |
Function library |
processing storage and Retrieve the function of published articles |
output_fns.php |
Function library |
Function of outputHTML |
create_data base.sql |
SQL | Establish the SQLscript |
3. Implement the database
CREATE DATABASE discussion; #创建论坛数据库 USE discussion; #使用论坛数据库 CREATE TABLE header #创建数据头表 ( parent INT NOT NULL, #父文章的postid poster CHAR(20) NOT NULL, #该文章的作者 title CHAR(20) NOT NULL, #该文章的标题 children INT DEFAULT 0 NOT NULL, #该文章是否有回复,0无,1有,默认0 area INT DEFAULT 1 NOT NULL, #备用于扩展时,实现多个论坛的多个版块 posted datetime NOT NULL, #该文章的发表的时间和日期 postid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY #每篇文章的唯一的ID ); CREATE TABLE body #创建正文表 ( postid INT UNSIGNED NOT NULL PRIMARY KEY, #每篇文章的唯一的ID message text #该文章的正文 ); GRANT SELECT,INSERT,UPDATE,DELETE ON discussion.* TO discussion@localhost IDENTIFIED BY 'password';
4. Implement the source code
Download address: One Simple PHP Web Forum
The above introduces a simple PHP Web forum, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.