PHP implementation of the Message board Text Code Tutorial

Source: Internet
Author: User

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.

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.