【发布时间】:2019-06-17 11:09:02
【问题描述】:
我正在使用 CodeIgniter 创建一个应用程序。
当我输入正确的电子邮件和密码时,我应该被重定向到仪表板,但我得到了这个重定向:/auth/login 并显示
我可以澄清一下,我允许 mod_rewrite ,添加了 write base_url 并允许在 apache 上连接
我的 Config.php
$config['base_url'] = 'http://127.0.0.1:8000/stock-v2/';
我的控制器:
public function login()
{
$this->logged_in();
$this->form_validation->set_rules('email', 'Email', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
if ($this->form_validation->run() == TRUE) {
// true case
$email_exists = $this->model_auth->check_email($this->input->post('email'));
if($email_exists == TRUE) {
$login = $this->model_auth->login($this->input->post('email'), $this->input->post('password'));
if($login) {
$logged_in_sess = array(
'id' => $login['id'],
'username' => $login['username'],
'email' => $login['email'],
'logged_in' => TRUE
);
$this->session->set_userdata($logged_in_sess);
redirect('dashboard', 'refresh');
}
else {
$this->data['errors'] = 'Incorrect username/password combination';
$this->load->view('login', $this->data);
}
}
else {
$this->data['errors'] = 'Email does not exists';
$this->load->view('login', $this->data);
}
}
else {
// false case
$this->load->view('login');
}
}
*/
public function logout()
{
$this->session->sess_destroy();
redirect('auth/login', 'refresh');
}
谁能帮忙?
【问题讨论】:
-
控制器中是否有名为 Dashboard.php 的索引函数?
-
是的,我有索引
-
错误提示
page you requested is missing,您的仪表板控制器代码在哪里? -
我有一个名为 controller 的文件夹,仪表板控制器位于其中,auth 也是身份验证控制器,登录只是一个功能,所以当我按下登录时,它必须将我重定向到仪表板而不是 auth\登录(我提到作为应用程序的默认控制器
标签: php codeigniter redirect