Php implements the message board function (Code details) and message board details

Source: Internet
Author: User
Tags php foreach

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!

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.