Welcome Guest, Not a member yet? Register   Sign In
Passing two values to custom validation
#2

[eluser]Pascal Kriete[/eluser]
It's pretty simple - if your validation looks like this:
Code:
$rules['username'] = "trim|required|max_length[20]|xss_clean";
$rules['password'] = "required|callback_checkLogin";

You would make a checkLogin function that looks like this:
Code:
function checkLogin($pw)
    {
        $this->load->model('User_model');
        
        $un = $this->input->post('username');
        
        if($this->User_model->checkCredentials($un, $pw))
        {
            $this->session->set_userdata('logged_in', TRUE);
            return true;
        }
        else
        {
            $this->validation->set_message('checkLogin', 'Credentials do not match.');
            return false;
        }
    }
Then in your internal pages you would check if the session data is set to true - and if it isn't you would redirect.


Messages In This Thread
Passing two values to custom validation - by El Forum - 01-17-2008, 06:54 AM
Passing two values to custom validation - by El Forum - 01-17-2008, 09:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB