bbs发帖核心代码

Posted echopp

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了bbs发帖核心代码相关的知识,希望对你有一定的参考价值。

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

//加载数据库
include DIR_CORE.‘mysqlDB.php‘;

//接受发帖页面传送的数据
$title = addslashes(strip_tags(trim($_POST[title])));
$content = addslashes(strip_tags(trim($_POST[content])));

//判断数据的合法性
if(empty($title) || empty($content)){
    header("refresh:2;url=./publish.php");
    die("标题或内容不能为空!请重新填写!");
}

//数据入库
//create table publish(
//    pub_id int unsigned primary key auto_increment comment ‘主键ID‘,
//    pub_title varchar(50) not null comment ‘帖子标题‘,
//    pub_content text not null comment ‘帖子内容‘,
//    pub_owner varchar(20) not null comment ‘发帖作者‘,
//    pub_time int unsigned not null comment ‘发帖时间‘,
//    pub_hits int unsigned not null comment ‘浏览次数‘
//);
$owner = "游客";
$time = time();

$sql = "insert into publish values(null,‘$title‘,‘$content‘,‘$owner‘,$time,default)";

$result = my_query($sql);
if($result){
    //执行成功
    header("location:./list_father.php");
}else{
    header("refresh:2;url=./publish.php");
    die("发生未知错误!发帖失败,请重新发帖");
}


以上是关于bbs发帖核心代码的主要内容,如果未能解决你的问题,请参考以下文章

Atitit. Atiposter 发帖机版本历史 编年史

论坛的发帖达人这个功能的sql怎么写?

文本编辑器,求助一款和百度贴吧发帖那样的

Fiddler数据拦截及篡改

此代码中是不是缺少某些内容?我无法通过 axios 发帖请求发帖

如何在朋友的墙上发帖?