为了账号安全,请及时绑定邮箱和手机立即绑定

缺少小于 ( < ) 和大于 ( > ) 特殊字符的 HTML POST

缺少小于 ( < ) 和大于 ( > ) 特殊字符的 HTML POST

PHP
慕村225694 2021-10-15 16:03:04
使用解决的问题$_REQUEST['editor1']而不是 $_POST['editor1']。不完全确定为什么。希望对遇到这个奇怪问题的人有所帮助。============================================问题描述:我正在将 CKeditor 集成到我的 HTML 表单中。Ckeditor 成功显示在表单上,我可以输入一些数据。但是当我尝试发布表单以存储在数据库中时,我注意到数据库条目缺少所有 HTML 左括号和右括号。试图在互联网上搜索但没有运气。请指教。我的数据库字段具有文本类型。我已经用 TinyMCE 替换了 Ckeditor,但还是一样。<div class="form-group">    <label for="content"><?=$str['content']?></label>        <div class="input-group mb-3">        <textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="20"></textarea>    </div></div><!-- Initializing the editor --><script src="//cdn.ckeditor.com/4.12.1/full/ckeditor.js"></script><script type="text/javascript">    CKEDITOR.replace( 'editor1' );</script>我尝试使用以下数据输入 ckeditor textarea:<h3><a href="https://stackoverflow.com/questions/22904776/insert-ckeditor-html-code-into-the-database">Insert ckeditor html code into the database - Stack Overflow</a></h3><p>&nbsp;</p><p><a href="https://stackoverflow.com/questions/22904776/insert-ckeditor-html-code-into-the-database"><cite>https://stackoverflow.com/questions/.../insert-ckeditor-html-code-into-the-database</cite></a></p>但是当我存储在数据库中或检索 $_POST['editor1'] 数据时,我得到了这个:h3a href=https://stackoverflow.com/questions/22904776/insert-ckeditor-html-code-into-the-databaseInsert ckeditor html code into the database - Stack Overflow/a/h3 p /p pa href=https://stackoverflow.com/questions/22904776/insert-ckeditor-html-code-into-the-databasecitehttps://stackoverflow.com/questions/.../insert-ckeditor-html-code-into-the-database/cite/a/p缺少所有左括号和右括号。我做错了什么?下面是存储数据的代码:if (isset($_POST['submit'])) {    $host     = DB_HOST; /* Host name */    $user     = DB_USER; /* User */    $password = DB_PASS; /* Password */    $dbname   = DB_NAME; /* Database name */    $con = mysqli_connect($host, $user, $password, $dbname);// Check connection    if (!$con) {        die("Connection failed: " . mysqli_connect_error());    }
查看完整描述

3 回答

?
元芳怎么了

TA贡献1798条经验 获得超7个赞

使用html_entity_decode转换HTML实体成HTML标签

echo html_entity_decode($_POST['editor1']);

参考链接在这里


查看完整回答
反对 回复 2021-10-15
?
慕后森

TA贡献1802条经验 获得超5个赞

使用此检查:mysqli_real_escape_string()同时添加到数据库


查看完整回答
反对 回复 2021-10-15
  • 3 回答
  • 0 关注
  • 173 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信