ci表单提交数据问题求助
各位前辈,大家好!我用CI搭了个博客,后台发表文章的时候用了kindedit编辑器,文章的主题内容提交到后台控制器,再调用模型插入数据库。验证表单用了form_validation类,验证规则应该没有错,有时候能插入数据,有时候插入就是空的。(就是说有时候能正常发表,有时候发表为空)这个比较苦恼。
后台关键代码:
控制器表单验证规则:
//var_dump($_POST);//这里打出来的表单数据都是对的
$this->form_validation->set_rules('title', '文章标题', 'required|min_length');
$this->form_validation->set_rules('type', '类型', 'required|integer');
$this->form_validation->set_rules('cid', '栏目', 'integer');
$this->form_validation->set_rules('info', '摘要', 'required|max_length');
$this->form_validation->set_rules('content', '内容', 'required');
//$status = $this->form_validation->run('article');
//post数据打包到数组
$data = array(
'title' => $this->input->post('title'),
'type' => $this->input->post('type'),
'cid' => $this->input->post('cid'),
'thumb' => $thumb_name,
'info' => $this->input->post('info'),
'content'=> $this->input->post('content'),
'time' => time()
);
//p($data);die;//有时候这里打出来的数据content字段是空的值,其他的都是有值的
$this->art->add($data);
在art模型中:
public function add($data){
//p($data);die;
$this->db->insert('article', $data);
}
前台表单提交:
http://i1.tietuku.com/fc4d18f74b6b2eac.png
logs爆出的错误:
ERROR - 2015-07-19 13:34:56 --> Severity: Warning--> preg_replace(): Compilation failed: regular expression is too large at offset 37678 D:\Program_Tools\wamp\www\ci\system\core\Security.php 642
ERROR - 2015-07-19 13:34:57 --> Severity: 8192--> mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead D:\Program_Tools\wamp\www\ci\system\database\drivers\mysql\mysql_driver.php 91
ERROR - 2015-07-19 13:54:23 --> Severity: Warning--> preg_replace(): Compilation failed: regular expression is too large at offset 37678 D:\Program_Tools\wamp\www\ci\system\core\Security.php 642
ERROR - 2015-07-19 13:54:23 --> Severity: 8192--> mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead D:\Program_Tools\wamp\www\ci\system\database\drivers\mysql\mysql_driver.php 91
各位前辈帮忙看看指点指点,这个问题困扰好久了,搜都没有解决方案,在这里先谢谢各位前辈了!
@Hex
@版主
自己顶一下。
再说下前台表单域:
<form action="<?php site_url('admin/article/send')?>" method="POST" enctype="multipart/form-data" name="atricleform">
效果:
http://i1.tietuku.com/4ee8867bead899f0.png
http://i1.tietuku.com/7cdf7d9543229f65.png
谷歌搜素关键词:Warning: preg_match_all(): Compilation failed: regular expression is too large at offset
答案也没有,尝试了http://stackoverflow.com/questions/8268624/php-preg-match-all-limit上边的方法也没效果。
<?php
// essential for huge PCREs
ini_set("pcre.backtrack_limit", "23001337");
ini_set("pcre.recursion_limit", "23001337");
// imagine your PCRE here...
?> 配置文件中$config['global_xss_filtering'] 如果开启了,试着设置成 FALSE,看看是否还出问题!
pcjingl 发表于 2015-7-19 14:54
配置文件中$config['global_xss_filtering'] 如果开启了,试着设置成 FALSE,看看是否还出问题!
...
感谢解答!刚才试了下,发布了几篇,好像都正常了。
重新看了下global_xss_filtering说明。之前没想到这个会把输入的数据改掉这么严重。
再次感谢 @pcjingl 前辈。
现在贴出解决方法(也不知道对不对,有不对的希望前辈们指正)如下:
如@pcjingl 前辈说的将$config['global_xss_filtering'] = TRUE;改为FALSE,
然后在要对某个输入值进行XSS过滤的地方使用
$this->input->post('fieldName', TRUE); 第二个参数表示是否启用XSS过滤,TRUE表示启用。
这样这个警告信息也没有了:
ERROR - 2015-07-19 13:54:23 --> Severity: Warning--> preg_replace(): Compilation failed: regular expression is too large at offset 37678 D:\Program_Tools\wamp\www\ci\system\core\Security.php 642
页:
[1]