Simple PHP Message Board production
To do the basic message board function requires three sheets:
Employee table, message form, friend table
First create a login page:
<form action= "drcl.php" method= "POST" > <p> Account: <input type= "text" Name= "Zhang"/></p> <p> Password: <input type= "Text" Name= "Mi"/></p><input type= "submit" value= "Log In"/></form >
:
Not much, no problem.
Then, to write the processing page:
<?phpsession_start ();//session storage data include ("db.class.php");//reference class $DB = new db ();//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; Before you jump to the page, save the account to the session header ("location:zym.php");} else{ echo "failed to log in";}? >
The normal processing of the login page just saved the account session
Log in and go to the main page
Here is the main page:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
The criteria for finding out is to check only your friends or all of them.
It is also important to note that the db of the call is set to a global variable
Figure
Message board need to publish information:
Publishing Information page:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">The last is the processing page for publishing information:
<?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 in To Liuyan values (' ', ' {$uid} ', ' {$JSR} ', ' {$SJ} ', ' {$neirong} ', 0) ', if ($db->query ($sql, 0)) { header ("Location: Zym.php ");} else{ echo "failed to publish! ";}
Figure:
I use Floret's account to send a message to Xiaoming:
So log into Xiaoming's account
Figure:
Yes, he's got this message from Floret.