【问题标题】:summernote text not storing into databaseSummernote 文本未存储到数据库中
【发布时间】:2014-12-09 05:41:42
【问题描述】:

我正在使用summernote编辑文本,当我通过summernote工具栏或菜单为文本赋予样式时,它会出现,但是在提交文本和html标签后存储在数据库中,样式由此转义。

<div id="summernote"><?php echo stripslashes($career['description']); ?></div>
                    <textarea class="form-control" id="deschere" name="desc" placeholder="Description" rows="20" style="display: none;"></textarea>

脚本

<script type="text/javascript">
$('#thisform').submit(function(e){
    $('#deschere').html($('#summernote').code());
    console.log($('#deschere').html());
    //e.preventDefault();
});

存储在数据库中的代码

$data['title']= $this->input->post('title');
$data['description']= $this->input->post('desc');
$data['date']=date('Y/m/d h:i');
$id=$this->input->post('id');
$this->db->where('id',$id);
$response=$this->db->update('careers',$data);
return $response;

有人对此有解决方案吗? 谢谢。

【问题讨论】:

    标签: php summernote


    【解决方案1】:

    1.检查application/config/config.php中的XSS过滤 $config['global_xss_filtering'] = TRUE;设置为假;因为它会从summernote中删除内联样式。

    1. $this->input->post('desc', FALSE);设置为 FALSE

    【讨论】:

      【解决方案2】:

      也许当您将数据插入数据库时​​,标签会自动删除?

      【讨论】:

      • 那我该怎么办?,我在控制器上使用 var_dump(),仍然没有 css 文本
      • 你使用什么样的框架?看起来像 CodeIgniter,对吧?在数据库中一切正常吗?列描述包含html标签等?
      猜你喜欢
      • 2016-11-28
      • 2017-01-03
      • 2015-08-03
      • 1970-01-01
      • 1970-01-01
      • 2021-11-30
      • 1970-01-01
      • 1970-01-01
      • 2011-11-14
      相关资源
      最近更新 更多