I have now got the system going through the process however for some reason, the code for actually updating the password in the database isn't updating anything? After insert new password and re-password, system immediately redirect to the login page, Even though no errors are shown? Any thoughts? thanks.

This is my Reset Function

```
function reset($token=null){
    $this->User->recursive=-1;
    if(!empty($token)){
        $u=$this->User->findBytokenhash($token);
        if($u){
            $this->User->id=$u['User']['id'];
            if($this->request->is('post')){
                $this->User->data=$this->request->data;
                $this->User->data['User']['username']=$u['User']['username'];
                $new_hash=sha1($u['User']['username'].rand(0,100));//created token
                $this->User->data['User']['tokenhash']=$new_hash;
                // print_r($this->request->data);
                //      exit;
                if($this->User->validates(array('fieldList'=>array('password','password_confirm')))){
                    if($this->User->save($this->User->data)){
                        $this->Session->setFlash('Password Has been Updated');
                        $this->redirect(array('controller'=>'users','action'=>'login'));
                    }
                } else{
                    $this->set('errors',$this->User->invalidFields());
                }
            }
        } else {
            $this->Session->setFlash('Token Corrupted,,Please Retry.the reset link work only for once.');
        }
    } else{
        $this->redirect('/');
    }
}

```

And this is my reset.ctp

```
<?php echo $this->Form->create('User', array('action' => 'reset')); ?>
<?php
    if(isset($errors)){
        echo '<div class="error">';
        echo "<ul>";
        foreach($errors as $error){
            echo "<li><div class='error-message'>$error</div></li>";
        }
        echo "</ul>";
        echo '</div>';
    }
?>
<form method="post">
    <?php
        echo $this->Form->input('User.password', array('type' => 'password',
                                                       'name' => '$data[User][password]',
                                                       'class' => 'form-control'));
        echo $this->Form->input('User.re_password', array('type' => 'password',
                                                        'name' => 'data[User][re_password]',
                                                        'class' => 'form-control'));
    ?>
    <input type="submit" class="button" style="float:left;margin-left:3px;" value="Save" />
    <?php echo $this->Form->end();?>
</form>

```

Please, help me , thanks