title: Password Hash and in Codeigniter
body: <p>I can hash the password during user registration,but comparing them from the user input during login with the one in the database isn't working.getting errors.
  This is the insert for registration.Kindly show me where i'm going wrong</p>
  
  <pre><code> public function insert_client($codeDigits)
   {
      $options = ['cost'=&gt;12];
      $response = $this-&gt;taken_email($_POST['Email']);
      if($response){
          $returned = false;
      }else{
              $this-&gt;FirstName    = $_POST['FirstName']; 
              $this-&gt;LastName    = $_POST['LastName'];
              $this-&gt;Email     = $_POST['Email'];  
              $this-&gt;Role_Id     = 2;  
              $this-&gt;Password =  password_hash($_POST['Password'],PASSWORD_BCRYPT,$options);
              $this-&gt;PhoneNo    = $_POST['PhoneNo'];
              $this-&gt;confirmCode    = $codeDigits;
              $this-&gt;db-&gt;insert('users', $this);
              $returned = true;
          }            
          return $returned;
      }
  </code></pre>
  
  <p>This is the login model,the query for login</p>
  
  <pre><code> public function login_model2($email,$password)
   {   
     $options = ['cost'=&gt;12];
     $this-&gt;db-&gt;select('*');
     $this-&gt;db-&gt;from('users');
     $this-&gt;db-&gt;where('Email',$email);
     //$this-&gt;db-&gt;where('Password',$password);
     $this-&gt;db-&gt;where('Role_Id !=',1);
     $query = $this-&gt;db-&gt;get();
  
     if($query-&gt;num_rows() &gt; 0)
     {
         $data = $query-&gt;row(); 
  
         // storing the results in the variable $data        
             if(password_verify($password,$data-&gt;password))
             {           
                return true;
              }            
              else
              {
                  return false;
                  }                 
     }
  
     else
      {
         return false;
         }       
     }
  </code></pre>
  
  <p>This is the login controller function when logging in</p>
  
  <pre><code> public function post_login2()
  {
      $this-&gt;form_validation-&gt;set_rules('Email', 'Email', 'trim|required|min_length[6]');
      $this-&gt;form_validation-&gt;set_rules('Password', 'Password', 'trim|required|min_length[6]');
  
      if($this-&gt;form_validation-&gt;run() == TRUE ){ 
          if($this-&gt;Users_model-&gt;login_model2($_POST['Email'],$_POST['Password']))
          {
              //test for redirect
  
              if ($_SESSION['role'] == 2) {
  
                  redirect("Client/welcome");
  
              } else if ($_SESSION['role'] == 3) {
  
                  redirect("Pro/welcome");
  
              }
  
            // test for redirect
          }else{
              // 
              $this-&gt;session-&gt;set_flashdata('err', true);
              redirect("Welcome/login");
          }
  
      }else{
  
          $this-&gt;login();
      }
  }
  </code></pre>