Php implements the message board function, and php implements the message board function.

Source: Internet
Author: User
Tags php foreach

Php implements the message board function, and php implements the message board function.

This small message board function is suitable for class or internal discussions, conversations, and messages. It is very convenient, and more importantly, it does not require the Internet. It is very common for the company's management,

The message board is written as follows:

1 first, the login page:

<Form action = "chuli. php "method =" post "> <div style =" margin-left: 500px; margin-top: 200px; height: 250px; width: 250px ">/* to place the login table in the middle of the page, it is more beautiful */

2. After the logon page is complete, enter the logon processing page, that is, the chuli. php file submitted above.

<? Phpsession_start (); // After logging on, You must connect the included logon page and enable sessioninclude ("DADB. class. php "); $ db = new DADB (); $ user = $ _ POST [" username "]; $ pwd = $ _ POST [" password "]; $ SQL = "select password from yuangong where username = '{$ user}'"; $ arr = $ db-> Query ($ SQL ); if ($ arr [0] [0] ==$ pwd &&! Empty ($ pwd) {$ _ SESSION ["username"] = $ user; header ("location: main. php ") ;}else {echo" Logon Failed ";}?>

Is the logon page

3. After logging on to the console, you can view the dialog content you have received. The following figure shows the table and Page code of the database:

<Body> <div> 

4. The code is written here, and the important part is completed. The following is the release information page, which is equivalent to the previously added page, the processing page is no different from the previous one. The difference is that the current processing page is operated upon user login, and the session needs to be used to connect all the login pages.

<H1> Publish information 

A simple message board has been completed. When you exit, you need to clear the session and return to the logon page.

// Exit the page Code <? Phpsession_start (); unset ($ _ SESSION ["username"]); header ("location: login. php");?>

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.