php开发留言板之页面提交php文件
留言板页面提交php文件

<?php
include ("conn.php");
$id=$_POST['id'];
$user=$_POST['user'];
$title=$_POST['title'];
$content=$_POST['content'];
if ($_POST['submit']){
$sql="insert into message(id,user,title,content,lastdate)values('','$user','$title','$content',now())";
mysql_query($sql);
echo "<script>alert('提交成功!返回首页。');location.href='add.html';</script>";
}
?>调用数据库连接文件,当点击submit时用post提交方式,使用sql语insert into 对message表内的id user title content lasdata 写入文件
echo "<script>alert('提交成功!返回首页。');location.href='add.html';</script>";
是使用js来进行弹窗提示并返回。
难点:
$_POST的使用和获取方法
新建文件
<?php
include ("conn.php");
$id=$_POST['id'];
$user=$_POST['user'];
$title=$_POST['title'];
$content=$_POST['content'];
if ($_POST['submit']){
$sql="insert into message(id,user,title,content,lastdate)values('','$user','$title','$content',now())";
mysql_query($sql);
echo "<script>alert('提交成功!返回首页。');location.href='add.html';</script>";
}
?>
预览
Clear
- 课程推荐
- 课件下载
课件暂不提供下载,工作人员正在整理中,后期请多关注该课程~ 















