: This article mainly introduces a simple PHP web forum. For more information about PHP tutorials, see. 1. requirement analysis
- Start a new discussion by posting an article
- Post an article to reply to an existing article
- View published articles
- View conversation topics in the forum
- View the relationship between articles, that is, view which article is replied to by another article
2. solutions
2.1 Forum Design
2.2 files used in Web forum applications
File name |
Type |
Description |
Index. php |
Applications |
The user enters the site to see the home page. Including the list of all articles on the site that can be expanded and deleted |
New_post.php |
Applications |
Form used to post new articles |
Store_new_post.php |
Applications |
Save the article that has been entered into the new_post.php form |
View_post.php |
Applications |
Displays a list of individual articles and articles that reply to them. |
Treenode_class.php |
Function library |
Contains the node class. we will use it to show the inheritance relationship of the article. |
Include_ Fns. php |
Function library |
Put all other function libraries used in this program together (other library types are listed here) |
Data_valid_fns.php |
Function library |
Data validation functions |
Db_fns.php |
Function library |
Database connection functions |
Discussion_fns.php |
Function library |
Function for processing storage and re-obtaining published articles |
Output_fns.php |
Function library |
Output HTML functions |
Create_database. SQL |
SQL |
Create the SQL script for the database required by the program |
3. implement databases
Create database discussion; # CREATE a forum database use discussion; # USE the forum database create table header # CREATE a data header TABLE (parent int not null, # postidposter CHAR (20) not null in the parent article, # title CHAR (20) not null, # title of this article children int default 0 not null, # whether the article has a reply, 0 none, 1 has, the DEFAULT value is 0 area int default 1 not null. # when used for expansion, the system implements posted datetime not null for multiple forum sections in multiple forums, # postid int unsigned not null AUTO_INCREMENT primary key # Unique ID of each article ); create table body # CREATE a body TABLE (postid int unsigned not null primary key, # unique IDmessage text of each article # The body of this article); grant select, INSERT, UPDATE, DELETEON discussion. * TO discussion @ localhost identified by 'password ';
4. source code implementation
: A simple PHP Web forum
The above introduces a simple PHP Web forum, including some content, and hopes to help those who are interested in PHP tutorials.