08-06-2023, 03:47 PM
My view:
<tr>
<td>Username</td>
<td><?php echo $this->Form->input('User.username', array('label' => '')); ?></td>
</tr>
<tr>
<td>Password</td>
<td><?php echo $this->Form->password('User.password', array('label' => '', 'value'=>'')); ?></td>
</tr>
My controller:
function edit($id = null) {
$this->User->id = $id;
$data = $this->data;
# print_r($data);
if (empty($data)) {
$this->data = $this->User->read();
} else {
if ($this->User->save($data)) {
$this->Session->setFlash('The user details have been updated.');
$this->redirect(array('action' => 'index'));
}
}
}
At the moment when I submit the form with a blank password the hash in the database still changes. How can I only update the password hash if a new password has been filled in.
Thanks.
EDIT: $data['User']['password'] is always a hash and never empty!
<tr>
<td>Username</td>
<td><?php echo $this->Form->input('User.username', array('label' => '')); ?></td>
</tr>
<tr>
<td>Password</td>
<td><?php echo $this->Form->password('User.password', array('label' => '', 'value'=>'')); ?></td>
</tr>
My controller:
function edit($id = null) {
$this->User->id = $id;
$data = $this->data;
# print_r($data);
if (empty($data)) {
$this->data = $this->User->read();
} else {
if ($this->User->save($data)) {
$this->Session->setFlash('The user details have been updated.');
$this->redirect(array('action' => 'index'));
}
}
}
At the moment when I submit the form with a blank password the hash in the database still changes. How can I only update the password hash if a new password has been filled in.
Thanks.
EDIT: $data['User']['password'] is always a hash and never empty!