CodeIgniter Forums
Unsuccessful Login - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Unsuccessful Login (/showthread.php?tid=71396)



Unsuccessful Login - rsekibira - 08-09-2018

I am new to codeIgniter but I am facing a challenge with login functions.
Look at the code below and advice; This is my logincontroller
<?Php
    class Logincontroller extends CI_Controller{
        public function index(){
            $this->load->view('login');
        }
        public function checklogin(){
            $this->form_validation->set_rules('username', 'Username', 'required');
            $this->form_validation->set_rules('password', 'Password', 'required|callback_verifyuser');
        if ($this->form_validation->run()==false) {
           
           $this->load->view('login');
        }else{
            redirect('homecontroller/index');

        }
        }
        public function verifyuser(){
            $username=$this->input->post('username');
            $password=$this->input->post('password');

            $this->load->model('loginmodel');

            if($this->loginmodel->login($username,$password)) {
                 
                  return true;
            }else{
                $this->form_validation->set_message('verifyuser', 'Incorrect Username or Password. Please try again');
                return false;
            }
        }
    }
   ?>
I use correct login details but it returns this error message "I 'Incorrect Username or Password. Please try again'
Any advice
Thanks


RE: Unsuccessful Login - jreklund - 08-09-2018

If the username/password are indeed correct your $this->loginmodel->login() are broken.