If you use a field called password, I'm not sure but I think that Cake
automatically hash it. you have to compare $this->auth->password($this-
>data['User']['confirm_password']) to $this->data['User']
['password'];

see http://book.cakephp.org/view/565/Troubleshooting-Auth-Problems

On Oct 21, 3:45 pm, Valheru <[EMAIL PROTECTED]> wrote:
> I am trying to compare to (password) fields in a form, using CakePHP
> 1.2. Calling a method "confirmpassword" in the controller results in a
> Javascript error:
>
> Notice (8): Undefined index:  confirm_password [APP\controllers
> \users_controller.php, line 60]
>
> $this->autoRender=false;
>
> $password = $this->data['User']['password'];
>
> $confirmpassword = $this->data['User']['confirm_password'];
>
> UsersController::checkpassword() - APP\controllers
> \users_controller.php, line 60
> Object::dispatchMethod() - CORE\cake\libs\object.php, line 114
> Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 259
> Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 213
> [main] - APP\webroot\index.php, line 9
>
> The code is as follows:
>
> function checkpassword() {
>                         $this->autoRender=false;
>                         $password = $this->data['User']['password'];
>                         $confirmpassword = 
> $this->data['User']['confirm_password'];
>
>                         if (!empty($password))
>                         {
>
>                                 if (!$this->User->validates($field = 
> array($password)))
>                                 {
>                                         echo "<span class=\"error\">Invalid 
> password</span>";
>                                 }
>                                 else
>                                 {
>                                         if ($password !== $confirmpassword)
>                                         {
>                                                 echo "<span 
> class=\"error\">Passwords must match</span>";
>                                         }
>                                         else
>                                         {
>                                                 echo "<span 
> class=\"success\">Passwords match</span>";
>                                         }
>                                 }
>                         }
>         }
>
> As you can see the two fields in the form are calls "password" and
> "confirm_password". The password field is being found fine, but
> confirm_password isn't. "password" is a field in the "users" table of
> my database, "while "confirm_password" isn't - is this maybe causing
> the problem?  And how can I solve this? Thanks in advance.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to