Codeigniter: validation problem

Posted by krike on Stack Overflow See other posts from Stack Overflow or by krike
Published on 2010-06-09T11:57:45Z Indexed on 2010/06/09 12:02 UTC
Read the original article Hit count: 189

Filed under:
|
|
|

For some reason a user can login with any password, first I thought I forgot to check for the password but I didn't... and I just cant find the problem

here is the model:

/*#######################################################*/
    function validate()
/*#######################################################*/
    {
        $this->db->where('username', $this->input->post('username'));
        $this->db->where('password', md5($this->input->post('password')));
        $q = $this->db->get('user_extra');

        if($q->num_rows() == 1):
            return true;
        else:
            return false;
        endif;
    }//end of function validate()

The controller

/*#######################################################*/
        function validate_credentials()
/*#######################################################*/
        {
            $this->load->model('membership_model');

            $this->load->library('form_validation');

            $this->form_validation->set_rules('username', 'Name', 'trim|required');
            $this->form_validation->set_rules('password', 'password', 'trim|required');
            if(!$this->membership_model->validate()):
                $this->form_validation->set_message('check_login', 'Login not correct, please try again.');
            endif;

            if($this->form_validation->run() == FALSE):
                $this->index();
            else:
                $this->membership_model->userinfo($this->input->post('username'));
                //should redirect to last view
                redirect($this->session->flashdata('redirect_url'));
            endif;
        }// end of validate_credentials()

© Stack Overflow or respective owner

Related posts about php

Related posts about authentication