我有以下功能,应该在成功时重定向到另一个页面:
public function process() {
$username = $this->input->post('username');
$password = $this->input->post('password');
// Validate the user can login
$result = $this->login_model->validate($username, $password);
// Now we verify the result
if (!$result) {
if (empty($password)) {
$msg = '<font color=red>Invalid username and/or password.</font><br />';
$this->index($msg);
} else {
$msg = '<font color=red>Invalid username and/or password.</font><br />';
$this->index($msg);
}
} else {
// If user did validate,
// Send them to members area
redirect('home');
}
}
如果它有效,那么我应该被重定向到家,但不幸的是我收到以下错误:
HTTP ERROR: 500
Internal Server Error
RequestURI=http://system.uniqueloo.co.ke/login/process
我是否有另一种方法可以在不使用php重定向功能的情况下在codeigniter中进行重定向?
答案 0 :(得分:0)
确保索引函数接受传入参数
在控制器中
public function process() {
$username = $this->input->post('username');
$password = $this->input->post('password');
$result = $this->login_model->validate($username, $password);
if (isset($result)) { #change this
if (empty($password)) {
$msg = '<font color=red>Invalid username and/or password.</font><br />';
$this->index($msg); # not sure about this
}
else {
$msg = '<font color=red>Invalid username and/or password.</font><br />';
$this->index($msg); # not sure about this
}
}
else {
redirect('home');
}
}