加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

简单的PHP留言本实例代码

发布时间:2020-12-13 05:42:59 所属栏目:PHP教程 来源:网络整理
导读:config.php 代码如下: $conn = @mysql_connect("localhost","root","") or die("数据库连接出错!"); mysql_select_db("gb",$conn); mysql_query("set names 'GBK'"); ?> add.php 代码如下: include("config.php"); if($_POST['submit']){ //在这里的时候,忘

config.php


代码如下:
$conn = @mysql_connect("localhost","root","") or die("数据库连接出错!");
mysql_select_db("gb",$conn);
mysql_query("set names 'GBK'");
?>

add.php


代码如下:
include("config.php");
if($_POST['submit']){
//在这里的时候,忘记message里还有个字段lastdate没有写,导致插入数据不成功。找了好久才找出错误。
$sql="insert into message (id,user,title,content,lastdate) values ('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
mysql_query($sql);
echo "成功";
}
?>
用户:

标题:

内容: