用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1807|回复: 2
收起左侧

[已解决] CI form_valid 只支持post吗,我用了put,感觉校验不起效

[复制链接]
发表于 2016-12-5 20:33:34 | 显示全部楼层 |阅读模式
PHP复制代码
         $this->form_validation->set_rules('old_password', 'Old password', 'required');
//         $this->form_validation->set_rules('new_password', 'New Password', 'required|min_length['.$this->config->item('min_password_length', 'ion_auth').']|max_length['.$this->config->item('max_password_length', 'ion_auth').']|matches[new_password_confirm]');
//         $this->form_validation->set_rules('new_password_confirm', 'Confirm New Password', 'required');
 
        $put = $this->input->input_stream();
        $id = $put['id'];
 
        //校验
        if( $put['new_password'] != $put['new_password_confirm'] ){
            echo json_encode(array('status'=>'error','message'=>'两次输入的密码不匹配'));
            exit;
        }
 
        $user = $this->ion_auth->get_user($id);
 
        if ($this->form_validation->run())
        {
 
复制代码



发表于 2016-12-6 14:06:31 | 显示全部楼层
你说对了,只支持 POST,不过你可以把 PUT 参数放到 $_POST 这个变量里。
 楼主| 发表于 2016-12-9 16:50:35 | 显示全部楼层
Hex 发表于 2016-12-6 14:06
你说对了,只支持 POST,不过你可以把 PUT 参数放到 $_POST 这个变量里。

好的,我覆盖下库试试

本版积分规则