title: Confirm password in CodeIgniter
body: <p>I'm building a blog with CodeIgniter 3.1.3 and I have a feature in the admin to add new users. When I try to add a new user I get the following error:</p>
  
  <blockquote>
    <p>The Password field does not match the confirm_password field.</p>
  </blockquote>
  
  <p>although the given password in password and confrom password field is the same.</p>
  
  <p>I can't figure out what causes the problem.</p>
  
  <p><strong>Here is my model:</strong></p>
  
  <pre><code>public function insert($data){
      $this-&gt;db-&gt;insert('users', $data);
      return true;
  }
  </code></pre>
  
  <p><strong>Here is my controller</strong></p>
  
  <pre><code>public function add(){
          //Validation Rules
          $this-&gt;form_validation-&gt;set_rules('first_name','First Name','trim|required');
          $this-&gt;form_validation-&gt;set_rules('last_name','Last Name','trim|required');
          $this-&gt;form_validation-&gt;set_rules('email','Email','trim|required|valid_email');
          $this-&gt;form_validation-&gt;set_rules('username','Username','trim|required|min_length[3]');
          $this-&gt;form_validation-&gt;set_rules('password', 'Password', 'required|matches[confirm_password]');
  
          $data['groups'] = $this-&gt;User_model-&gt;get_groups();
  
          if($this-&gt;form_validation-&gt;run() == FALSE){
              //Views
              $data['main_content'] = 'admin/users/add';
              $this-&gt;load-&gt;view('admin/layouts/main', $data);
          } else {
              //Create Data Array
              $data = array(
                  'first_name'    =&gt; $this-&gt;input-&gt;post('first_name'),
                  'last_name'     =&gt; $this-&gt;input-&gt;post('last_name'),
                  'username'      =&gt; $this-&gt;input-&gt;post('username'),
                  'password'      =&gt; md5($this-&gt;input-&gt;post('password')),
                  'group_id'      =&gt; $this-&gt;input-&gt;post('group'),
                  'email'         =&gt; $this-&gt;input-&gt;post('email')
              );
  
              //Table Insert
              $this-&gt;User_model-&gt;insert($data);
  
              //Create Message
              $this-&gt;session-&gt;set_flashdata('user_saved', 'User has been saved');
  
              //Redirect to pages
              redirect('admin/users');
          }
  </code></pre>
  
  <p><strong>Here is my view:</strong></p>
  
  <pre><code>&lt;div class="row"&gt;
                          &lt;div class="col-lg-12"&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label&gt;First Name&lt;/label&gt;
                                  &lt;input class="form-control" type="text" name="first_name" value="&lt;?php echo set_value('first_name'); ?&gt;" placeholder="Enter First Name" /&gt;
                              &lt;/div&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label&gt;Last Name&lt;/label&gt;
                                  &lt;input class="form-control" type="text" name="last_name" value="&lt;?php echo set_value('last_name'); ?&gt;" placeholder="Enter Last Name" /&gt;
                              &lt;/div&gt;  
                              &lt;div class="form-group"&gt;
                                  &lt;label&gt;Email Address&lt;/label&gt;
                                  &lt;input class="form-control" type="email" name="email" value="&lt;?php echo set_value('email'); ?&gt;" placeholder="Enter Email" /&gt;
                              &lt;/div&gt;  
                              &lt;div class="form-group"&gt;
                                  &lt;label&gt;Username&lt;/label&gt;
                                  &lt;input class="form-control" type="text" name="username" value="&lt;?php echo set_value('username'); ?&gt;" placeholder="Enter Username" /&gt;
                              &lt;/div&gt;  
                              &lt;div class="form-group"&gt;
                                  &lt;label&gt;Password&lt;/label&gt;
                                  &lt;input class="form-control" type="password" name="password" value="&lt;?php echo set_value('password'); ?&gt;" placeholder="Enter Password" /&gt;
                              &lt;/div&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label&gt;Confirm Password&lt;/label&gt;
                                  &lt;input class="form-control" type="password" name="confirm_password" value="&lt;?php echo set_value('confirm_password'); ?&gt;" placeholder="Confirm Password" /&gt;
                              &lt;/div&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label&gt;User Group&lt;/label&gt;
                                  &lt;select name="group" class="form-control"&gt;
                                       &lt;?php foreach($groups as $group) : ?&gt;
                                      &lt;option value="&lt;?php echo $group-&gt;id; ?&gt;"&gt;&lt;?php echo $group-&gt;name; ?&gt;&lt;/option&gt;
                                   &lt;?php endforeach; ?&gt;   
                                  &lt;/select&gt;
                              &lt;/div&gt;  
  
                      &lt;/div&gt;&lt;!-- /.row --&gt;
  </code></pre>