php自治简单留言板代码
php自治简单留言板代码
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php $lianjie = mysql_connect("localhost", "root", "xiaolie") or die("连接失败"); mysql_query("set names utf8"); if (@$_POST["ok"]) { mysql_select_db("xiaolie"); //插入数据 $shuju = " insert into hao (name,neirong,shijian) values ('" . $_POST["name"] . "','" . $_POST["neirong"] . "','" . date("Y-m-d H:m:s") . "')"; $fasong = mysql_query($shuju) or die(mysql_error()); if ($fasong) { header("location:/a2/ly.php"); } else { echo "内容发表失败<br><a href=fb_my.php>返回</a>"; } } else { /* mysql_select_db("xiaolie"); //发送查询 $fasong = mysql_query("select * from hao") or die(mysql_error()); while($nr = mysql_fetch_array($fasong)) { echo "<table border=1> <tr> <td width='60'>第 ".$nr["id"]." 楼</td> <td width='140'>发表用户:".$nr["name"]."</td> <td width='230'>发表时间:".$nr["shijian"]."</td> </tr> <tr><td colspan='3' width='430'>".$nr["neirong"]."</td></tr> </table>"; } */ ?> <form method=post action=fb_my.php> 姓名<input type=text name="name" /><br> 发表<br><textarea name="neirong" cols="50" rows="5"></textarea><br> <input type=submit name="ok" value="好的" /> </form> <?php } ?>
本文地址:http://www.phprm.com/code/0584ffa937b24f1a0e647891ea2ece16.html
转载随意,但请附上文章地址:-)