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);
}
}