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

[HELP] 验证 form 无法返回错误

[复制链接]
发表于 2016-3-24 20:29:58 | 显示全部楼层 |阅读模式
用ci 3.x 在练习写一个blog遇到一些问题http://localhost/blog/post/6 这是其中一篇文章
文章下方有个回应文章的功能,提交的路由为
http://localhost/blog/comments/add_comment/6

问题:
如果form_validation= FALSE , redirect 后, 為什麼无法显示 form_error 信息,
请问是哪里出问题了呢?  


class Comments extends CI_Controller {
       
        public function __construct()
        {
                parent::__construct();

        }
        public function add_comment($post_id){
                        $name = $this->input->post('name',true);
                           $email = $this->input->post('email',true);
                           $comment = $this->input->post('comment',true);

                           $this->form_validation->set_rules("name", "name", "trim|required");
                           $this->form_validation->set_rules("email", "email", "trim|required");
                           $this->form_validation->set_rules("comment", "comment", "trim|required");
                       
                                if ($this->form_validation->run() == FALSE)
                                {
                                        redirect('post/$post_id);
                                }
                                else
                                {
       
                                       
                                }


                }       



发表于 2016-3-25 09:58:15 | 显示全部楼层
redirect('post/$post_id);
这里跳转走了,错误不会被携带,
另外,视图中需要输出错误。

本版积分规则