Welcome Guest, Not a member yet? Register   Sign In
Best practice for Login/Password form validation errors?
#3

[eluser]Twisted1919[/eluser]
You can do it with form validation too , using callbacks , see user guide for this .
But usually , you need to run the validation against the data from database after the user passes the rules from form validation, so you would have something like :

Code:
if( $this->form_validation->run() == FALSE )
{
$data['error'] = validation_errors() ;
}
else
{
if( $this->class_or_model->auth($username,$password) == FALSE )
   {
   $data['error'] = 'Invalid credentials';
   }
else
   {
   //set the session and redirect .
   }
}

$this->load->view('your-view-with-login-form',$data);

//In your view you would have something like :
if( ! empty($error) ){
echo $error ;
}
Of course , there are allot of ways to do this one . Lately i use only ajax for working with forms , but the above code should make sense .


Messages In This Thread
Best practice for Login/Password form validation errors? - by El Forum - 01-19-2010, 12:58 PM



Theme © iAndrew 2016 - Forum software by © MyBB