Php implements the message board function (Code details) and message board details
Simple PHP message board Creation
The basic message board function requires three tables:
Employee table, comment table, and friend table
Create a login page:
<Form action = "drcl. php "method =" post "> <div> account: <input type =" text "name =" zhang "/> </div> <div> password: <input type = "text" name = "mi"/> </div> <input type = "submit" value = "login"/> </form>
:
Not to mention, no problem
Then write the processing page:
<? Phpsession_start (); // session storage data include ("db. class. php "); // reference class $ db = new db (); // creation method $ zhang =$ _ POST [" zhang "]; $ mi = $ _ POST ["mi"]; $ SQL = "select mi from yuangong WHERE zhang = '{$ zhang }'"; $ arr = $ db-> Query ($ SQL); if (! Empty ($ mi) & $ mi = $ arr &&! Empty ($ zhang) {$ _ SESSION ["zhang"] = $ zhang; // Save the account to the header ("location: zym. php ") ;}else {echo" Login Failed ";}?>
Normally, the login page only saves the session to the account.
Log on to the master page
The following is the Home Page:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Only your friends or all people can be queried.
Note that the called db should be set as a global variable.
Figure:
Message Board needs to publish information:
Release information page:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
The processing page for publishing information is as follows:
<? Phpsession_start (); $ uid = $ _ SESSION ["zhang"]; include (".. /db. class. php "); $ db = new db (); $ jsr = $ _ POST [" shou "]; $ neirong = $ _ POST [" lynr "]; $ sj = date ("Y-m-d H: I: s"); $ SQL = "insert into liuyan values ('', '{$ uid }', '{$ jsr}', '{$ sj}', '{$ neirong}', 0) "; if ($ db-> Query ($ SQL, 0 )) {header ("location: zym. php ");} else {echo" Release failed! ";}
Figure:
I used the account of Xiaohua to send a message to Xiaoming:
Therefore, log on to James's account
Figure:
Yes. He received the message from Xiaohua.
The above is all the content of this article. I hope this article will help you in your study or work. I also hope to provide more support to the customer's home!