Message book example analysis (1)

Source: Internet
Author: User

Message book
Implementation tools-PHP and MySQL 5.0
Overview:
This article introduces the design ideas and procedures of the message book. While introducing the development process of the message book, it also provides a comprehensive understanding of some common functions and programming skills and ideas in PHP, you can also learn a lot of PHP programming skills to comprehensively improve your personal basic and programming skills.
Knowledge:
1. Master the design and process of the message book
2. Master the design methods and methods of the MySQL database.
3. Learn how to connect PHP to the MySQL database
4. flexible use of common SQL query statements
5. Learn how to display data by page in PHP
Function:
Apart from the functions available in the message book, such as message, view, reply, query, and delete
The Administrator management function is also available.

Business Process:
Yes
User --> Fill in the User Registration Information --> determine whether the user information is legal --> Save the user registration information --> the user registration is successful
^ |
| No |
--------------- |
Yes v
Delete reply message <----- reply to other messages <----- publish a message <--- determine whether the logon information is valid <--- enter the logon information
| NO ^
----> Log out --------------------


Example directory:
\ --- Root directory
│ Admin_browse.php --- moderator page
│ Bottom. php --- webpage copyright page file
│ Cale. php --- store Perpetual calendar files
│ Calendar. js --- calendar File
│ Chklogin. php --- verify the self-Logon File
│ Chkuserlogin. php --- user identity authentication File
│ Deleteleaveword. php --- Delete the message file
│ Deletereplyword. php --- Delete the message reply File
│ Editleaveword. php --- edit user message page
│ Edlitreplyword. php --- edit user message reply page
│ Filterwords.txt --- store sensitive Word Files
│ Function. php --- system function File
│ Gllogout. php --- moderator exit page
│ Index. php --- message home page
│ Leaveword. php --- message page
│ Left. php --- left navigation page of message book
│ Login. php --- moderator logon page
│ Logout. php --- user exit page
│ Lookleaveword. php --- view the message page
│ Lookxx. php --- details page
│ Main. php --- message Topic Page
│ Readme.txt
│ Reg. php --- user registration page
│ Reply. php --- user reply message page
│ Saveleaveword. php --- save the user message page
│ Savereg. php --- save the user reply message page
│ Savereply. php --- save the user reply message page
│ Searchword. php --- query the user message page
│ Top. php --- website header banner page

├ ── Conn --- used to store the database link files used by the website
│ Conn. php

├ ── CSS --- directory for storing CSS style files
│ Style.css

─ ── Data --- Database Backup
│ Mongo── db_guestbook --- Database Name
│ DB. Opt
│ Tb_adm.frm
│ Tb_adm.myd
│ Tb_adm.myi
│ Tb_leaveword.frm
│ Tb_leaveword.myd
│ Tb_leaveword.myi
│ Tb_replyword.frm
│ Tb_replyword.myd
│ Tb_replyword.myi
│ Tb_user.frm
│ Tb_user.myd
│ Tb_user.myi

Pai── images --- used to store website image resource files
│ Banner.jpg
│ Banner_r1_c1.jpg
│ Banner_r2_c1.jpg
│ Biao.gif
│ Bottom.gif
│ Dh_back.gif
│ Dh_back_1.gif
│ Email.gif
│ Gly.gif
│ Ip.gif
│ Line_down.gif
│ Mark_0.gif
│ Mark_1.gif
│ Qq.gif
│ Thumbs. DB

└ ── Face
0. gif
1. gif
10. gif
11. gif
2. gif
3. gif
4. gif
5. gif
6. gif
7. gif
8. gif
9. gif
Thumbs. DB
Analysis:

Database Analysis
Use MySQL database
Database Name: db_guestbook
Data Table: tb_adm --- moderator Information
Tb_leaveword --- message
Tb_replyword --- reply message
Tb_user --- user information
User Information (tb_user)
| --- ID
| --- Username usermc
| --- Password userpwd
| --- Email
| --- Avatar face
| --- Real name truename
| --- Registration time: regtime

Message (tb_leaveword)
| --- ID
| --- Message holder userid
| --- Message topic createtime
| --- Content
| --- Message time: createtime
| --- Message holder iduserid

Reply message (tb_replyword)
| --- ID
| --- Reviewer ID leave_id
| --- Reply topic titles
| --- Reply content Contents
| --- Response Time: createimes
| --- Reply to message iduserid

Moderator information (tb_adm)
| --- ID
| --- Moderator name userword
| --- Moderator Password
| --- Moderator email
| --- Moderator IP Address
Create Database Language
Create a database:
Create Database 'db _ guestbook '/*! 40100 default Character Set utf8 */
Statement for creating a data table:
Create Table 'tb _ ADM '(
'Id' int (5) not null,
'Userword' varchar (20) not null,
'Password' varchar (20) not null,
'Email 'varchar (30) not null,
'IP' varchar (10) Not null,
Primary Key ('id ')
) Engine = MyISAM default charset = utf8;

Create Table 'tb _ leaveword '(
'Id' int (8) Not null auto_increment,
'Userid' int (8) Not null,
'Createtime' datetime not null,
'Title' varchar (100) not null,
'Content' text not null,
Primary Key ('id ')
) Engine = MyISAM default charset = utf8

Create Table 'tb _ replyword '(
'Userid' int (4) not null,
'Createtimes 'datetime not null,
'Tidles 'varchar (100) not null,
'Contents' text not null,
'Leave _ id' int (4) not null,
'Id' int (4) not null auto_increment,
Primary Key ('id ')
) Engine = MyISAM default charset = utf8

Create Table 'tb _ user '(
'Id' int (8) Not null auto_increment,
'Usernc 'varchar (50) not null,
'Truename' varchar (50) not null,
'Email 'varchar (50) not null,
'Qq' varchar (20) not null,
'Tel 'varchar (20) not null,
'IP' varchar (15) not null,
'Address' varchar (250) not null,
'Face' varchar (50) not null,
'Regtime' datetime not null,
'Sex 'varchar (2) not null,
'Usertype' int (2) not null,
'Userpwd' varchar (50) not null,
Primary Key ('id ')
) Engine = MyISAM default charset = utf8;

Modify Encoding
The database and table code in the original book is gb2312
To learn this example in the configured environment, you need to modify the encoding method of the database.

Solutions for searching online:
1. if the encoding for installing MySQL cannot be changed, many of our friends purchase a virtual host to create a website and do not have the right to change the encoding for installing MySQL. We can skip this step as long as the subsequent steps are correct, the same solution can solve the garbled problem.
2. Modify the database encoding. If the database encoding is incorrect, run the following command in phpMyAdmin:
Alter database 'test' default Character Set utf8 collate utf8_bin
The preceding command sets the encoding of the test database to utf8.
3. Modify the table encoding:
Alter table 'category 'default Character Set utf8 collate utf8_bin
The preceding command changes the category encoding of a table to utf8.
4. Modify the field encoding:
Alter table 'test' change 'dd' dd' varchar (45) Character Set utf8 collate utf8_bin not null
The preceding command is to encode the DD field in the test table to utf8.
5. If this is the case, you only need to check the page and modify the charset of the source file.

Note: You can use show create table table_name;
To view the table creation statements.



Message book example analysis (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.