Q:

UserName - Password check function returning "false"

I'm having some trouble managing my login for a website. I've tried several different methods and queries which all seem to lead to the same problem: the method I use to check username and password always returns false.
To make it easier to understand, here's what I'm trying to do:

Controller file calls view page and prompts user for username and password
I'm using a callback function to set a rule for the form
the callback function calls Model method
Model method returns TRUE if login details are correct and FALSE otherwise.

Apparently it always returns FALSE as the login never works ...  
I'm using CodeIgniter.
Controller file:
class Login extends CI_Controller {

  public function __construct()
  {
    parent::__construct();
    $this->load->helper(array('form', 'url'));
    $this->load->library(array('form_validation', 'session'));
  }

  public function index()
  {
    $this->form_validation->set_rules('username', 'Username', 'callback_login_check[password]');

    if ($this->form_validation->run() == FALSE) {
      //loading view as long as it is not correct
      $this->load->view('login');
    } else {
      //temporary successful login page
      $this->load->view('success');
    }
  }

  public function login_check($usr, $pwd)
  {
    $this->load->database();
    $this->load->model('EZ_Query');

    $result = $this->EZ_Query->get_user_details($usr, $pwd);

    if ($result == TRUE) {
      return TRUE;
    } else {
      $this->form_validation->set_message('login_check', 'Password does not match Username');
      return FALSE;
    }
  }
}

Model file:
class EZ_Query extends CI_Model {

  public function get_user_details($usr, $pwd)
  {
    $sql = "SELECT *
              FROM PROFIL
              WHERE USER = '$usr'
              AND MDP = '$pwd'";

    $query = $this->db->query($sql);

    if ($query->num_rows() == 1) {
      $row = $query->row();

      //session variables
      $data = array('name' => $row->NOMPROFIL,
                    'fname' => $row->PRENOMPROFIL,
                    'type' => $row->TYPEPROFIL);
      $this->session->set_userdata($data);

            return TRUE;
    } else {
      return FALSE;
    }
  }
}

Less useful, here's part of login view page:
<body>
    <?php
      echo validation_errors();
      echo form_open('Login');
      echo form_label('Username', 'username');
      echo form_input('username')."<br />";
      echo form_label('Password', 'password');
      echo form_password('password')."<br />";
      echo form_submit('sumbit', 'Enter');
      echo form_close();
    ?>
  </body>

Sorry for bad english, and thanks for your help.

A:

I have changed a couple of things on here for you to try
I hope you are using a good hash for passwords NOT MD5 use http://php.net/manual/en/function.password-hash.php and http://php.net/manual/en/function.password-verify.php
Filename: Login.php
<?php

class Login extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->helper(array('form', 'url'));
        $this->load->library(array('form_validation', 'session'));
        // Autoload the session because you may need it else where
    }

    public function index() {
        // remove the word password from callback as it on the username 
        // login all ways good to use required

        $this->form_validation->set_rules('username', 'Username', 'trim|required|callback_login_check');
        $this->form_validation->set_rules('password', 'Password', 'trim|required');

        if ($this->form_validation->run() == FALSE) {

            //loading view as long as it is not correct
            $this->load->view('login');

        } else {

            //temporary successful login page
            $this->load->view('success');
        }
    }

    public function login_check()
    {
        $usr = $this->input->post('username');
        $pwd = $this->input->post('password');

        $this->load->database(); // Autoload database best.

        // Filename of model should be Ez_query.php and same with class only first letter upper case

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

        $result = $this->ez_query->get_user_details($usr, $pwd);

        if ($result == TRUE) {
            return TRUE;
        } else {
            $this->form_validation->set_message('login_check', 'Password does not match Username');
            return FALSE;
        }
    }
}

