title: Password is not matching while logging in
body: <p>I have this code while registering the form:</p>
  
  <pre><code>function register()
      {
  $this-&gt;form_validation-&gt;set_rules('txt_username', 'Username', 'trim|required');
  $this-&gt;form_validation-&gt;set_rules('cpassword', 'Confirm Password', 'trim|required|matches[txt_password]|md5');
  $this-&gt;form_validation-&gt;set_rules('txt_password', 'Password', 'trim|required|md5');  
  //other codes
  
  
  $data = array('username' =&gt; $this-&gt;input-&gt;post('txt_username'),
                'password' =&gt; $this-&gt;input-&gt;post('txt_password')
              );
  
              // insert form data into database
             if ($this-&gt;account_model-&gt;insertUser($data));
               { 
              $this-&gt;session-&gt;set_flashdata('msg','successfully registered!');
              redirect('account/register');
          }
  }
  </code></pre>
  
  <p>the password matches here.
  but when i use same data to username and password to login: it displays invalid username or password:
  the login function is as follows:</p>
  
  <pre><code>function login()
  {
                      //set validations
            $this-&gt;form_validation-&gt;set_rules("txt_username", "Username", "trim|required");
            $this-&gt;form_validation-&gt;set_rules("txt_password", "Password", "trim|required");
  
                $username = $this-&gt;input-&gt;post("txt_username");
                $password = $this-&gt;input-&gt;post("txt_password");
  
                  $usr_result = $this-&gt;account_model-&gt;get_user($username, $password);
  
                      if ($usr_result &gt; 0) //active user record is present
                      {
                      $this-&gt;account_model-&gt;login();
              $data['message'] ="You are logged in!"; 
          }
                      else
                      {
          $this-&gt;session-&gt;set_flashdata('msg', 'Invalid username and password!');
                      }
          }
  }
  </code></pre>
  
  <p>I have this model for inserting registration form data to database:</p>
  
  <pre><code>function insertUser($data)
      {
          return $this-&gt;db-&gt;insert('user', $data);
      }
  </code></pre>
  
  <p>and i have this model to retreive data to login:</p>
  
  <pre><code>function get_user($usr, $pwd)
       {
            $sql = "select * from user where username = '" . $usr . "' and password = '".md5($pwd). "'";
            $query = $this-&gt;db-&gt;query($sql);
            return $query-&gt;num_rows();
       }
  </code></pre>