帖子无HTML编辑,包含html标签的帖子显示无格式

我在写一个简单的类似于cms的解决方案来跟踪我愚蠢的想法。 一切都很顺利,但我现在遇到一些困难,将辛哈RTE插件应用到我的应用程序中。包含html标签的帖子显示无格式

我按照他们的现场教程,它似乎是工作,但...

当进行格式化的文本,标题段落等。虽然这些标签正确在MySQL数据库中保存的:

heading

text example

它们显示为:

heading

text example

(concatenated and NOT formatted , displaying tags in stead)

<p>tesy</p> <h4>fgfg<br /></h4> <h2> </h2>

最后一个例子输出是因为我做了这个变化:

//$postCon = mysql_real_escape_string($postCon);

$postCon = htmlspecialchars($postCon);

,因为有人在他们的论坛上表示,这将是“愚蠢的”,以HTML特殊字符这是唯一的 - 因为HTML标签是由其中。

我有一个很艰难的时期确定的实际问题。因此我的问题有点草率。我希望现在有些地方已经存在,并且能够向正确的方向提供一些解释或指导。

我会去饮咖啡,并在此思考现在,并带来更新,如果我得到任何新的东西。 现在我只想给你留下处理邮件的实际脚本。

感谢,

include_once 'bin/configDb.php';

include_once 'bin/connectDb.php';

include_once 'header.php';

//get stuff from post

$topicSub = $_POST['topic_subject'];

//$topicSub = mysql_real_escape_string($topicSub);

$topicSub = htmlspecialchars($topicSub);

$topicCat = $_POST['topicCat'];

// $topicCat = mysql_real_escape_string($topicCat);

$sesId = $_GET['username'];

//the form has been posted, so save it

//insert the topic into the topics table first, then we'll save the post into the posts table

$postCon = $_POST['post_content'];

//$postCon = mysql_real_escape_string($postCon);

$postCon = htmlspecialchars($postCon);

$sql = "INSERT INTO

topics(topic_subject, topic_date, topic_cat, topic_by)

VALUES('$topicSub', NOW(), '$topicCat', '$sesId')";

$result = mysql_query($sql);

if(!$result)

{

//something went wrong, display the error

echo 'An error occured while inserting your data. Please try again later.' . mysql_error();

$sql = "ROLLBACK;";

$result = mysql_query($sql);

}

else

{

//the first query worked, now start the second, posts query

//retrieve the id of the freshly created topic for usage in the posts query

$topicId = mysql_insert_id();

$sql = "INSERT INTO

posts(post_content,

post_date,

post_topic,

post_by)

VALUES

('$postCon', NOW(), '$topicId', '$sesId')";

$result = mysql_query($sql);

if(!$result)

{

//something went wrong, display the error

echo 'An error occured while inserting your post. Please try again later.' . mysql_error();

$sql = "ROLLBACK;";

$result = mysql_query($sql);

}

else

{

$sql = "COMMIT;";

$result = mysql_query($sql);

//after a lot of work, the query succeeded!

echo 'You have successfully created your new topic.';

header("location:admin.php");

}

}

include_once 'footer.php';

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值