Detailed explanation of a PHP message board example (with source code download)_PHP tutorial

WBOY
Release: 2016-07-13 17:16:00
Original
1547 people have browsed it

The message board can be said to be a small WEB application that all PHP beginners will practice. Below I will share with you an example of a PHP message board I wrote. Students who need to know more can go to the reference .

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

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


You can directly import the data table structure

The code is as follows Copy code
CREATE TABLE `msgboard` (
 代码如下 复制代码
CREATE TABLE `msgboard` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `username` varchar(50) 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;
`id` int(10) NOT NULL AUTO_INCREMENT, `username` varchar(50) 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 adding, deleting and modifying messages

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'] : ''; //Leave a 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 "Incorrect input
";
}

$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'] . '


















Name:

Gender: Male   
​​​​​Female

Please leave a message:






Download a php message board example: http://file.bKjia.c0m/download/2013/06/08/msgboard.rar

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/628748.htmlTechArticleThe message board can be said to be a small WEB application that all PHP beginners will practice. Below I I would like to share an example of a php message board I wrote with all my classmates. Those who need to know more...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template