bbs回帖核心代码

<?php
//加载初始化文件
include '../init.php';

//加载数据库文件
include DIR_CORE.'MYSQLDB.php';

//接收表单传送过来的数据
$content = addslashes(strip_tags(trim($_POST['content'])));
$rep_pub_id= $_POST['pub_id'];
//判断数据的合法性
if(empty($content)){
    header("refresh:2;url=./reply.php");
    die("内容不能为空,请输入内容!");
}
//插入数据

$rep_owner = "游客";
$rep_time= time();

$sql = "insert into reply values(null,$rep_pub_id,'$rep_owner','$content',$rep_time)";
$result = my_query("$sql");

//判断数据是否插入成功,插入成功,跳转到回复页面,否则回复失败!
if($result){
    header("location:./show.php?pub_id=$rep_pub_id&action=reply");
}else{
    header("refresh:2;url=./reply.php");
    die("发生未知错误,请重新回复!");
}

posted @ 2016-12-03 00:16  echopp  阅读(220)  评论(0编辑  收藏  举报