Php implements the message board function (session control) and Message Board session

Source: Internet
Author: User

Php implements the message board function (session control) and Message Board session

The example in this article shares the code of the php message board function for your reference. The details are as follows:

Three tables used by the database

1. logon interface (denglu. php login. php)

1. denglu. php

<! DOCTYPE html> 

2. login. php

<? Phpsession_start (); $ UserName =$ _ POST ["UserName"]; $ PassWord =$ _ POST ["PassWord"]; require "DBDA. class1.php "; $ db = new DBDA (); $ SQL =" select PassWord from yuangong where UserName = '{$ UserName }'"; $ arr = $ db-> query ($ SQL); if (count ($ arr) {if ($ arr [0] [0] = $ PassWord &&! Empty ($ PassWord) {// storage UserName $ _ SESSION ["UserName"] = $ UserName; header ("location: main. php ") ;}} else {header (" location: denglu. php ");}

2. main Interface (main. php tuichu. php)

1. main. php

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

2. tuichu. php

<?phpsession_start();unset($_SESSION["UserName"]);header("location:denglu.php"); 

3. Sending page (fabu. php fabuchuli. php)

1. fabu. php

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

2. fabuchuli. php

<?phpsession_start();$UserName = $_SESSION["UserName"];$jsr = $_POST["jsr"];$nr = $_POST["neirong"];$Times = date("Y-m-d H:i:s");require"DBDA.class.php";$db = new DBDA();$sql = "insert into liuyan values('','{$UserName}','{$jsr}','{$Times}','{$nr}')";$db->query($sql,0);header("location:fabu.php");

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.