Welcome Guest, Not a member yet? Register   Sign In
password and username verification
#1

[eluser]terry101[/eluser]
I created a username/password check before and it worked fine for my login. I was trying to add a session with what i had before but i realized that now my password and username verification isnt work where it returns false. I don't see any difference in what i had before, not sure where i could have messed it up. I dont get any errors but when i type in a valid username/password (already stored in database) it gives me
Code:
echo 'Username or password is invalid, try again';
i tried
Code:
$this->output->enable_profiler(1);
and i see the query in the model is correct, its doing its job. Assistance needed.

Controller

Code:
function login()    {
        
                $this->load->library('form_validation');
        
        $this->form_validation->set_rules('username', 'Username','required|xss_clean|trim');
        $this->form_validation->set_rules('password', 'Password','required|xss_clean|trim');
        
        
        if ($this->form_validation->run() == FALSE) {
            
            $this->load->view('loginview');
        }
        else {
        
                $this->load->model('loginmodel');
                 $username = $this->input->post('username');
         $password = $this->input->post('password');
                if ($this->loginmodel->check_login($username, $password)){
                    
                    echo 'your in';
                        //$this->userlogin->start_session();
                    }
            
            else {
                
                echo 'Username or password is invalid, try again';
            
            }            
        }
    }
    
    function start_session() {
        
            // loading sessions
                $this->load->library('session');
                
                //$store_sess_data  = array ('logged_in' => TRUE, 'user_id' => $username, 'last_active' => 'timestamp')
                $this-> session->set_userdata(array (
                'logged_in' => TRUE,
                'user_id' => $username,
                'last_active' => 'timestamp')
                
                );
                  redirect('sessionview');
    }


Model

Code:
function check_login ($username, $password) {
        $en_password = MD5($password);
                
        $checklogin = array('username' => $username, 'password' => $en_password);
        $verifylogin = $this->db->get_where('tbregister',$checklogin);
    
        if ($verifylogin->num_rows() == 1) {
        var_dump($verifylogin);
            return TRUE;
        }
        else {
            
            return FALSE;
        }
    }




Theme © iAndrew 2016 - Forum software by © MyBB