php有数据库留言板源码 php留言板的简单编写
谁能提供一个PHP留言板源码
input.htm
镇平ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!
html
head
meta http-equiv="Content-Language" content="zh-cn"
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
titleinput/title
/head
body
form method="POST" action="receive.php"
p您的姓名: input type="text" name="T1" size="20"/p
p您的性别:男input type="radio" value="0" name="R1"
女input type="radio" name="R1" value="1"/p
p您的EMAIL:input type="text" name="T2" size="35"/p
p您的留言内容:/p
p textarea rows="16" name="S1" cols="45"/textarea/p
p /p
p input type="submit" value="提交" name="B1"
input type="reset" value="重置" name="B2"/p
/form
/body
/html
receive.php
?php
$user='root';
$password='123';
$db='guestbook';
$table='gbook';
$ip=getenv(REMOTE_ADDR);
$sql = "INSERT INTO `guestbook`.`gbook` (`id`, `name`, `sex`, `email`, `info`, `ip`, `time_at`) VALUES (NULL, '$T1', '$R1', '$T2', '$S1', '$ip', NOW());";
$connect=mysql_connect('localhost',$user,$password);
mysql_select_db($db);
mysql_query($sql);
$result=mysql_query("select * from $table");
while ($arr=mysql_fetch_array($result))
{
if ($arr[2]==0)
$gender='先生';
else
$gender='女士';
?
html
head
meta http-equiv="Content-Language" content="zh-cn"
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
titleReceive/title
/head
body style="background-attachment: fixed"
table border="1" width="100%" id="table1" bgcolor="#FFFFFF"
tr
td bordercolor="#FFFFFF" bgcolor="#C0C0C0"?=$arr[6]?(?=$arr[5]?)p?=$arr[1]? ?=$gender?a href="?=$arr[3]?"?=$arr[3]?/a
写到:/td
/tr
tr
td?=$arr[4]?p /p
pa href="del.php?id=?=$arr[0]?"[删除]/a
a href="modify.php?id=?=$arr[0]?"[修改]/a]/td
/tr
/table
/body
/html
?php
echo 'p';
echo 'p';
}
?
html
head
meta http-equiv="Content-Language" content="zh-cn"
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
title新建网页 1/title
/head
body
pa href="input.htm"继续留言/a/p
/body
/html
del.php
?php
$user='root';
$password='123';
$db='guestbook';
$table='gbook';
$sql="DELETE FROM $table WHERE id=$id";
$connect=mysql_connect('localhost',$user,$password);
mysql_select_db($db);
$result=mysql_query($sql);
if ($result)
echo "删除成功";
else
echo "删除失败";
?
html
head
meta http-equiv="Content-Language" content="zh-cn"
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
title新建网页 1/title
/head
body
pa href="receive.php"返回首页/a/p
/body
/html
modify.php
?php
$user='root';
$password='123';
$db='guestbook';
$table='gbook';
$ip=getenv(REMOTE_ADDR);
$connect=mysql_connect('localhost',$user,$password);
mysql_select_db($db);
$result=mysql_query("select * from $table where id=$id");
$arr=mysql_fetch_array($result);
?
html
head
meta http-equiv="Content-Language" content="zh-cn"
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
titleinput/title
/head
body
form method="POST" action="modify_ok.php?id=?=$id?"
p您的姓名: input type="text" name="T1" size="20" value="?=$arr[1]?"/p
p您的性别:
?php
if ($arr[2]==0) echo '男input type="radio" value="0" name="R1" checked
女input type="radio" name="R1" value="1"/p';
else echo '男input type="radio" value="0" name="R1"
女input type="radio" name="R1" value="1" checked/p';
?
p您的EMAIL:input type="text" name="T2" size="35" value="?=$arr[3]?"/p
p您的留言内容:/p
p textarea rows="16" name="S1" cols="45" ?=$arr[4]?/textarea/p
p /p
p input type="submit" value="修改" name="B1"
input type="reset" value="重置" name="B2"/p
/form
/body
/html
modify_ok.php
?php
$user='root';
$password='123';
$db='guestbook';
$table='gbook';
$connect=mysql_connect('localhost',$user,$password);
mysql_select_db($db);;
$sql = "UPDATE `guestbook`.`gbook` SET `name` = '$T1', `sex` = '$R1', `email` = '$T2', `info` = '$S1' WHERE `gbook`.`id` = '$id' LIMIT 1;";
$result=mysql_query($sql);
if ($result)
echo "修改成功";
else
echo "修改失败";
?
html
head
meta http-equiv="Content-Language" content="zh-cn"
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
title新建网页 1/title
/head
body
pa href="input.htm"继续留言/a/p
/body
/html
在网上下载的PHP留言板源码 要怎样才能浏览它整站的一个效果呢/ PHP文件都是分开编写的
你搭建一个php环境,实在不会可以下载一个wamp集成安装,然后把这个项目全部放在一个文件夹里,之后放在wamp安装目录下一个www的文件夹里。之后通过浏览器,输入:localhost,点击你新建的那个文件夹就可以
求用PHP写一个简单基本的留言板代码,有点急
数据库的创建
CREATE DATABASE GBOOK;
CREATE TABLE `gbook` (
`id` INT( 255 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 10 ) NOT NULL ,
`sex` TINYINT( 1 ) UNSIGNED NOT NULL ,
`email` VARCHAR( 255 ) NOT NULL ,
`info` TEXT NOT NULL ,
`ip` VARCHAR( 15 ) NOT NULL ,
`time_at` DATETIME NOT NULL
)
主要页面有:
input.html为初始页
insert.php为把输入内容送入数据库
show.php显示留言板内容
change.php修改留言板内容的界面
del.php删除留言板内容
change_ok.php修改留言板内容并送入数据库
input.html
html
head
meta http-equiv="content-type" content="text/html; charset=GB2312" /
title留言版/title
/head
body
form name="form1" method="post" action="insert.php"
p你的名字:input type="text" name="name" size="20" //p
p你的性别:input type="radio" value="1" name="sex" checked="checked" /男生 input type="radio" value="0" name="sex" /女生 /p
p你的E-mail:input type="text" name="email" size="20" //p
p你的留言内容:/p
ptextarea rows="9" name="info" cols="35"/textarea/p
pinput type="submit" value="提交" name="B1" /input type="reset" value="重设" name="B2" //p
/form
/body
/html
insert.php
?php
$mysql_server_name = "localhost";
$mysql_username = "root";
$mysql_password = "123456";
$mysql_database = "gbook";
$ip = getenv('REMOTE_ADDR');
$conn = mysql_connect("localhost","root","123456");
mysql_select_db("gbook");
$sql = "INSERT INTO `gbook` ( `id` , `name` , `sex` , `email` , `info` , `ip` , `time_at` )
VALUES (NULL , '$name', '$sex', '$email', '$info', '$ip', NOW( ))";
$result = mysql_query($sql,$conn);
$id = mysql_insert_id();
mysql_close($conn);
?
p留言成功/p
pa href="show.php"去留言页 /a/p
show.php
?
$mysql_server_name = "localhost";
$mysql_username = "root";
$mysql_password = "123456";
$mysql_database = "gbook";
$sql = "SELECT * FROM gbook ORDER BY 'id' DESC"; //排序 后留言的在前面显示
$conn = mysql_connect($mysql_server_name,$mysql_username,$mysql_password);
mysql_select_db($mysql_database,$conn);
$result = mysql_query($sql);
while($row = mysql_fetch_row($result))
{ // ----if语句判断男女------
if($row[2]==1)
{ $gender = '男';}
else
{ $gender = '女'; }
?
table width="752" border="1"
tr
td height="32"p?=$row[6]? ?=$row[5]? /p
p?=$row[1]?(?=$gender?) ?=$row[3]?/p/td
/tr
tr
td height="45"?=nl2br($row[4])?pa href="change.php?id=?=$row[0]?"[修改]/a a href="del.php?id=?=$row[0]?"[删除]/a/p/td
/tr
/table
hr /
?
}
mysql_free_result($result);
?
change.php
?
$mysql_server_name = "localhost";
$mysql_username = "root";
$mysql_password = "123456";
$mysql_database = "gbook";
$sql = "SELECT name, sex, email, info FROM gbook WHERE id = '$id' ";
$conn = mysql_connect($mysql_server_name,$mysql_username,$mysql_password);
mysql_select_db($mysql_database,$conn);
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
?
html
head
meta http-equiv="content-type" content="text/html; charset=GB2312" /
title留言版/title
/head
body
form name="form1" method="post" action="change_ok.php?id?=$id?"
p你的名字:input type="text" name="name" size="20" value="?=$row[0]?"//p
?
// -----if语句判断男女 1为男 0为女-------
if($row[1]==1)
echo ' p你的性别:input type="radio" value="1" name="sex" checked="checked" /男 input type="radio" value="0" name="sex" /女 /p';
else
echo ' p你的性别:input type="radio" value="1" name="sex" /男 input type="radio" value="0" name="sex" checked="checked" /女 /p';
?
p你的E-mail:input type="text" name="email" size="20" value="?=$row[2]?"//p
p你的留言内容:/p
ptextarea rows="9" name="info" cols="35"?=$row[3]?/textarea/p
pinput type="submit" value="提交" /input type="reset" value="重设" //p
/form
/body
/html
del.php
?
$mysql_server_name = "localhost";
$mysql_username = "root";
$mysql_password = "123456";
$mysql_database = "gbook";
$sql = "DELETE FROM gbook WHERE id = '$id' ";
$conn = mysql_connect($mysql_server_name,$mysql_username,$mysql_password);
mysql_select_db($mysql_database,$conn);
$result = mysql_query($sql);
mysql_close($conn);
?
pa href="show.php"[返回]/a/p
change_ok.php
?
$mysql_server_name = "localhost";
$mysql_username = "root";
$mysql_password = "123456";
$mysql_database = "gbook";
$sql = "UPDATE `gbook` SET `name` = '$name',`sex` = '$sex',`email` = '$email',`info` = '$info' WHERE `id` ='$id' ";
$conn = mysql_connect($mysql_server_name,$mysql_username,$mysql_password);
mysql_select_db($mysql_database,$conn);
$result = mysql_query($sql);
mysql_close($conn);
?
pa href="show.php"[返回]/a/p
文章标题:php有数据库留言板源码 php留言板的简单编写
URL网址:http://myzitong.com/article/dogdcph.html