prepare("SELECT password_hash FROM users WHERE id = ?"); $stmt->execute([$user_id]); $user = $stmt->fetch(PDO::FETCH_ASSOC); if ($user && password_verify($current_password, $user['password_hash'])) { if ($new_password === $confirm_password) { $hashed_password = password_hash($new_password, PASSWORD_DEFAULT); $stmt = $db->prepare("UPDATE users SET password_hash = ? WHERE id = ?"); $stmt->execute([$hashed_password, $user_id]); $success_message = t('password_changed_successfully'); } else { $error_message = t('passwords_do_not_match'); } } else { $error_message = t('incorrect_current_password'); } } // Fetch user data $stmt = $db->prepare("SELECT * FROM users WHERE id = ?"); $stmt->execute([$user_id]); $user = $stmt->fetch(PDO::FETCH_ASSOC); // Fetch client data if client_id is available $client = null; if (!empty($user['client_id'])) { $stmt = $db->prepare("SELECT * FROM clients WHERE id = ?"); $stmt->execute([$user['client_id']]); $client = $stmt->fetch(PDO::FETCH_ASSOC); } $page_title = t('profile_header'); require_once __DIR__ . '/includes/html_head.php'; require_once __DIR__ . '/includes/header.php'; ?>