diff --git a/app/Controllers/Users.php b/app/Controllers/Users.php index cca2665..43c93b5 100755 --- a/app/Controllers/Users.php +++ b/app/Controllers/Users.php @@ -339,9 +339,8 @@ class Users extends BaseController 'branch_id' => $this->request->getPost('branch'), 'isactive' => 1 // Assuming this is a default value or handled separately ]; - $user_id = $this->request->getPost('user_id'); - - if($user_id == 0){ + $user_id = trim($this->request->getPost('user_id')); // get and trim + if (empty($user_id) || $user_id == 0) { // Hash the password $password = $this->request->getPost('password'); $hashedPassword = password_hash($password, PASSWORD_DEFAULT); // Use PASSWORD_DEFAULT for bcrypt hashing @@ -354,7 +353,7 @@ class Users extends BaseController // Get user_id from the form // Check if user_id is provided - if (!empty($user_id)) { + if (!empty($user_id) && $user_id != 0) { // Update existing user $UsersModel->update($user_id, $data); } else {