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.