duanlidi1051 2019-07-18 06:05
浏览 117

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

2019.07.19 Update:

Issue resolved by using

$_REQUEST['editor1']

instead of $_POST['editor1']. Not entirely sure why. Hope it helps to anyone who came across this weird issue.

===========================================

Problem description:

I am integrating CKeditor to my HTML form. Ckeditor is showing on the form successfully, and I am able to enter some data. But when I tried to post the form in order to store in the database, I noticed that the database entry are missing all the HTML open brackets and close brackets. Tried to search on the internet but no luck. Kindly please advise.

My database field is having text type.

I have replaced Ckeditor with TinyMCE, but still the same.

<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>

I tried to input the ckeditor textarea with data below:

<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>

But when I stored in database or retrieving the $_POST['editor1'] data, I'm getting this:

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

All the open brackets and close brackets are missing. What did I do wrong?

Below is the code to store data:

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());
    }

    $subject      = $_POST['subject'];
    $content      = $_POST['editor1'];
    $publish      = $_POST['publish'];
    $publish_date = $_POST['publish_date'];
    $updated_by   = $_SESSION['memberID'];

    mysqli_query($con, " INSERT INTO tbl_announcement (subject, content, publish, publish_date, updated_by )
                VALUES ( '$subject', '$content', '$publish' , '$publish_date', '$updated_by')");
  • 写回答

3条回答 默认 最新

  • doubo1711 2019-07-18 06:15
    关注

    Check using this : mysqli_real_escape_string() while adding in database

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘