I believe that everyone who has been to OSO will be deeply impressed by OSO’s forum. This forum is excellent in every aspect. Do you want to have such a beautiful forum on your homepage? In fact, it is not too complicated. Below we will only imitate the OSO forum from some basic parts.
Since I only use this forum as my message board, my forum can be regarded as a simple match of the OSO forum. 1. In my forum, users can only speak after logging in. The user's ID is stored in a cookie variable called "cookie_user". 2. My forum does not have sub-forums. 3. I do not count the number of clicks on a topic. , 4. I have not designed the icon in front of each topic in the OSO forum to indicate whether there are new posts. 5. I have not considered the optional topic arrangement and display time period provided by the OSO forum. 6. There is no statistics on members’ posting points. 7. There is no function for moderators to manage the forum. 8. There is no function for editing posts. We will touch on how to extend these eight functions based on my program at the end.
First is the design of a database. In fact, a forum involves two data tables. Let’s temporarily name them user and guestbook. The user table stores the information of registered users. The creation statement is as follows:
create table my_user(
user_id char(12) not null,/*username*/
user_password varchar(8) not null,/*user password*/
PRIMARY KEY (user_id)
)
The guestbook stores the post content.The creation content is as follows:
CREATE TABLE guestbook (
id bigint DEFAULT '0' NOT NULL auto_increment,/*speak id, auto-increment field*/
name varchar(12) NOT NULL,/*topic creation Person*/
type tinyint NOT NULL,/*type 0-reply; 1-main post*/
theme varchar(50) NULL,/*theme*/
content blob NOT NULL,/*content */
icon tinyint NOT NULL,/*emoticon*/
time_open datetime not NULL,/*topic creation time*/
time_close datetime not NULL,/*last reply time*/
answer_count int not null,/*number of replies*/
answer_name varchar(12) not null,/*last replyer*/
main_id bigint null,/*main post id*/
PRIMARY KEY (id) /**/
);
The program contains five php source codes: connect.inc.php, faq.php, read.php, post.php, reply.php, post_end.php
connect.inc.php: (used to connect to the database)
$dbhostname = "localhost";
$dbusername = "";
$dbpassword = "";
$ dbName = "";
MYSQL_CONNECT($dbhostname, $dbusername, $dbpassword) OR DIE("Unable to connect to database");
@mysql_select_db( "$dbName") or die( "Unable to select database "); " ;