title: CakePHP - Password confirmation not allowing user to submit registration
body: <p>I'm trying to set up validation for user registration but I'm having troubles. When I <strong>only</strong> have the email,role and password fields in the $validation array (remove the others) it works and will save a new user. When I try to add the other fields it fails and gives the flash message error "The user could not be saved. Please, try again."</p>
  
  <p>I'm pretty sure it's the re_password check. When I remove the validation for that it works. However, the re_password validation does display an error when the passwords are different, so I'm not sure where to look </p>
  
  <p>Here's my users table</p>
  
  <pre><code>id  |  email  |  password  |  location  | website  | role  | created |  modified
  </code></pre>
  
  <p>Here's the validation requirements. To get it to save a new user I have to remove everything but email, password and role. </p>
  
  <pre><code>public $validate = array(
      'email' =&gt; 'email'
      ,
      'password' =&gt; array(
          'required' =&gt; array(
              'rule' =&gt; array('minLength', '8'),
              'message' =&gt; 'A password with a minimum length of 8 characters is required'
          )
      ),
      're_password' =&gt; array(
          'required' =&gt; array(
              'rule' =&gt; array('equalTo', 'password' ), 
              'message' =&gt; 'Both password fields must be filled out'
          )
      ),
      'role' =&gt; array(
          'valid' =&gt; array(
              'rule' =&gt; array('inList', array('admin', 'author')),
              'message' =&gt; 'Please enter a valid role',
              'allowEmpty' =&gt; false
          )
      ),
       'location' =&gt; array(
          'valid' =&gt; array(
              'rule' =&gt; array('notEmpty'),
              'message' =&gt; 'Please select a location'
          )
      )
  );
  </code></pre>
  
  <p>Here's the form (the options array is above, figured it's not necessary to show)</p>
  
  <pre><code>    echo $this-&gt;Form-&gt;input('email');
      echo $this-&gt;Form-&gt;input('password');
      echo $this-&gt;Form-&gt;input('re_password', array('type'=&gt;'password', 'label'=&gt;'Re-Enter Password', 'value'=&gt;'', 'autocomplete'=&gt;'off'));
      echo $this-&gt;Form-&gt;input('location', array('options' =&gt; $options, 'label' =&gt; 'Select Nearest Location'));
      echo $this-&gt;Form-&gt;input('website',array('label'=&gt;'Enter your website, such as www.example.com. ')); 
      echo $this-&gt;Form-&gt;input('role', array('type' =&gt; 'hidden', 'default' =&gt; 'user'));
  </code></pre>
  
  <p>Here's the re_password checking function in the User model</p>
  
  <pre><code>function check_user_password($userid) { 
      $salt = Configure::read('Security.salt');
      $this-&gt;User-&gt;id = $userid;
      $hashed_password = $this-&gt;User-&gt;field('password');
      // check password  
      if($hashed_password == md5($data['User']['re_password'].$salt)) {  
          return true;
      } else {
          return false;
      }
  }   
  </code></pre>
  
  <p>And finally, here's the add function in UsersController</p>
  
  <pre><code>public function add() {  
          if ($this-&gt;request-&gt;is('post')) {  
              $this-&gt;User-&gt;create();     //create initiates a form on User/add.ctp
              if ($this-&gt;User-&gt;save($this-&gt;request-&gt;data)) {  //save the form data
                  $this-&gt;Session-&gt;setFlash(__('The user has been saved'));
                  $this-&gt;redirect(array('controller' =&gt; 'demos', 'action' =&gt; 'index'));
              } else {
                  $this-&gt;Session-&gt;setFlash(__('The user could not be saved. Please, try again.'));
              }
          }
      }
  </code></pre>
  
  <p>Please let me know if there's anything else you need to see</p>