[eluser]TheFuzzy0ne[/eluser]
Ah, OK. I think I see where you're coming from. You just want to check if the third parameter is there in case of an error. In that case, I'd suggest that you check the third segment like this:
Code:
if ($this->uri->rsegment(3) == 'error')
{
# ...
Bear in mind that most people would expect an error message explaining what went wrong rather than just seeing an error page. You can use flash data for this, and then you can check for the flash data key rather than checking the segment.
Also (and this is just my own preference here), I'd implement loginAction() like this:
Code:
function loginAction()
{
$rules['username']="trim|required";
$rules['password']="trim|required|md5";
$this->validation->set_rules($rules);
if( ! $this->validation->run() || ! $this->User_model->checkUserLogin($this->input->post('username'),$this->input->post('password'))
{
redirect('user/login/error');
}
else
{
$this->session->set_userdata('logged_in',TRUE);
$this->session->set_userdata('name',$this->input->post('username'));
redirect('');
}
}
Functionally it's identical, but it's a little less code and I think a little easier to read IMHO.