This article mainly for you to introduce the PHP implementation of the message board function, session control cases, with a certain reference value, interested in small partners can refer to
This example for everyone to share the PHP message board function of the specific code for your reference, the specific content as follows
Three tables used in the database
I. Login 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 ($ar R) { if ($arr [0][0] = = $PassWord &&!empty ($PassWord)) { //store user name $_session["UserName"] = $ UserName; Header ("location:main.php");} } else{ Header ("location:denglu.php");}
Two. 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");
Three. Send 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");