将数据从表单传递到另一个表单时出现代码点火器表单验证问题


codeigniter form validation issue when passing data from form to another one

我在一个页面中有一个表单,它将输出数据传递给另一个包含另一个表单的页面。

问题是,当我尝试浏览第二个页面时,会显示该页面的验证错误,因为它在第1页的表单中看到POST数组,因此它没有通过验证错误所需的相同输入,所以它会显示验证消息。

以下是第二种形式的控制器中的代码:

function download_application()
{
    //load the libraries
    $this->load->library('form_validation');
    //form validation
    $this->form_validation->set_rules('name', 'name is required', 'required');
    $this->form_validation->set_rules('email', 'email  is required', 'required|valid_email');
    $this->form_validation->set_rules('country', 'country is required', 'required');
    $this->form_validation->set_rules('phone', 'phone is required', 'required');
    if($this->form_validation->run() == FALSE){
        //error in the form
    }else{
        //no error in the form          
    }
}

我有两个作为逻辑的解决方案,我没有写php,而是通过逻辑1.你可以给你的按钮添加值,在第二页检查这个值,如果它不等于值,那么你就没有验证它2.添加隐藏字段并将其传递给第二页中的此值

设置一个变量,将父窗体标识为海报,并根据该变量设置或取消设置当前窗体的窗体验证检查。

您应该让每个表单提交给自己,以便相关控制器处理自己的验证。验证通过后,您可以使用URL助手的redirect()函数或header("Location:..."); 将用户重定向到第二个控制器