我在codeigniter做项目。我的登录页面已成功执行。登录后我想重定向到home.php页面。我的登录代码只能成功执行,重定向方法存在问题。我还提供了我的目录结构供参考。
代码:
public function processlogin()
{
// $this->load->model('login_model');
// $show =true;
// $user = $this->login_model->showUser($show);
$username = $this->input->post('user_name');
$password = $this->input->post('password');
{
$this->load->model('login_model');
$this->load->database();
$query = $this->db->get_where('tbllogin', array('login_name' => $username,'password' => $password));
$count1 = count($query->result());
if($count1 === 1)
{
$this->load->helper('url');
redirect('login_page/home');
}
else
{
echo 'Error';
}
}
}
现在请告诉我应该在哪里放置重定向文件。
答案 0 :(得分:2)
public function processlogin()
{
// $this->load->model('login_model');
// $show =true;
// $user = $this->login_model->showUser($show);
$username = $this->input->post('user_name');
$password = $this->input->post('password');
{
$this->load->model('login_model');
$this->load->database();
$query = $this->db->get_where('tbllogin', array('login_name' => $username,'password' => $password));
$count1 = count($query->result());
if($count1 === 1)
{
$this->load->helper('url');
$this->load->view('login_page/home');
}
else
{
echo 'Error';
}
}
}