Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 重定向数据库中没有配置文件数据的位置_Php_Codeigniter_Redirect - Fatal编程技术网

Php 重定向数据库中没有配置文件数据的位置

Php 重定向数据库中没有配置文件数据的位置,php,codeigniter,redirect,Php,Codeigniter,Redirect,控制器 function view_profil(){ $id = $this->session->userdata('idtabelX'); $profil[''] = $this->class_model->function_model($id); $this->load->view('view_profil', $profil); } 模型 如果单击配置文件,它将显示存储在数据库中的数据用户配置文件,但如果用户在数据库中没有数据

控制器

function view_profil(){
    $id = $this->session->userdata('idtabelX');
    $profil[''] = $this->class_model->function_model($id);
    $this->load->view('view_profil', $profil);
}
模型

如果单击配置文件,它将显示存储在数据库中的数据用户配置文件,但如果用户在数据库中没有数据配置文件,我希望将用户重定向到插入页面以填充配置文件数据

非常感谢您帮助我解决此问题。

在您的控制器中-

    function view_profil(){
        $id = $this->session->userdata('idtabelX');
        $profil[''] = $this->class_model->function_model($id);

        //add this bit of code
        if($profil[''] == NULL)
        {
            redirect('your_controller/your_add_method');
        }
        else
        {
            $this->load->view('view_profil', $profil);
        }
    }

您需要使用
redirect()
函数,并将控制器插入方法的url作为参数传递。

好的,非常感谢您的帮助。StackOverflow作为学习和询问编程问题的媒介具有非常重要的作用。
    function view_profil(){
        $id = $this->session->userdata('idtabelX');
        $profil[''] = $this->class_model->function_model($id);

        //add this bit of code
        if($profil[''] == NULL)
        {
            redirect('your_controller/your_add_method');
        }
        else
        {
            $this->load->view('view_profil', $profil);
        }
    }