title: changing password in php/codeigniter
body: <p>i have created an admin page which is used to create account, delete account and change user password. i have problem with coding for changing password. below i attach codes created using codeigniter.(old password not required to change)</p>
  
  <p>front page has this:
  staff name:
  new password:
  confirm password:</p>
  
  <p><strong>controller file.</strong></p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
  class Admin extends MY_Controller {
  
      public function index()     
      {       
        $this-&gt;load-&gt;view('view-admin'); 
      } 
  
      public function chgPassword()       
      {   
          $query =&gt; $this-&gt;modeluser-&gt;changpasswrd();
          $this-&gt;load-&gt;view('view-chg-password');
          $this-&gt;view-chg-password-&gt;set_rules(‘npassword’,'New Password’,'required|trim’);
          $this-&gt;view-chg-password-&gt;set_rules(‘cpassword’,
                             'Confirm Password’,'required|trim|matches[npassword]‘);
  
      $this-&gt;session-&gt;set_flashdata('message', '&lt;span class="label label-info"&gt;Password changed!&lt;/span&gt; ');
      redirect(base_url().'admin/chgpassword');       
      }
  }
  </code></pre>
  
  <p><strong>model file.</strong></p>
  
  <pre><code> &lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class ModelUser extends CI_Model {
  
  public function changpasswrd($nama_staf, $password) {
   $this-&gt;db-&gt;set('password', $password);
    $this-&gt;db-&gt;where('nama-staf', $nama_staf);
  
    $this-&gt;db-&gt;update('akaun');
    return $this-&gt;db-&gt;affected_rows() &gt; 0; }
  
  
  function DeleteUser($options = array()) {
   // required values
   if(!$this-&gt;_required(array('userId'), $options)) return false;
  
   $this-&gt;db-&gt;where('userId', $options['userId']);
   $this-&gt;db-&gt;delete('users'); }
  </code></pre>
  
  <p>pls help me on this..</p>