A PHP Message Board instance detailed (with source download) _php Tutorial

Source: Internet
Author: User
Message board can be said to be all PHP beginners will practice a small web application, below I write a PHP message board instance I wrote to all of you, there is a need to understand the students can enter the reference.

1. Create a folder named "Msgboard" in the root directory of your PHP.

Create a "msglist.php" file under "Msgboard"


Data table structure you can import directly

The code is as follows Copy Code
CREATE TABLE ' Msgboard ' (
' id ' int (ten) is not NULL auto_increment,
' username ' varchar (CHARACTER SET latin1 not NULL,
' Sex ' tinyint (1) Not NULL DEFAULT ' 1 ',
' msg ' text CHARACTER SET latin1 not NULL,
PRIMARY KEY (' id ')
) Engine=myisam auto_increment=1 DEFAULT Charset=utf8;


msglist.php file, including message add, delete, modify

The code is as follows Copy Code




My message board


$username = isset ($_request[' username ')? $_request[' username ': '; Name
$sex = isset ($_request[' sex ')? Intval ($_request[' sex '): 1; Gender
$msg = isset ($_request[' msg ")? $_request[' msg ']: '; Message



Mysql_connect ("127.0.0.1", "root", "Lzy"); Link
mysql_select_db ("test"); Select Database

if (!empty ($username) &&!empty ($msg))
{
mysql_query ("INSERT into Msgboard (username,sex,msg) VALUES (' $username ', ' $sex ', ' $msg ')");
}
Else
{
echo "Input not correct
";
}

$source = mysql_query ("select * from Msgboard ORDER by ID DESC");
$result = Array ();

?>
















while ($row = Mysql_fetch_array ($source)) {echo ' '; Echo ' '; Echo ' '; }?>
Name Gender Message content
' . $row [' username ']. '' . ($row [' sex '] = = 1? ' Male ': ' Female '). '' . $row [' msg ']. '





A PHP message board instance download: Http://file.bKjia.c0m/download/2013/06/08/msgboard.rar

http://www.bkjia.com/PHPjc/628748.html www.bkjia.com true http://www.bkjia.com/PHPjc/628748.html techarticle Message board can be said to be all PHP beginners will practice a small web application, below I write a PHP message board instance I wrote to you, there is need to understand the same ...

  • 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.