pdo();
if ($pdo) {
$stmt = $pdo->prepare('SELECT display_name, first_name FROM user_profiles WHERE user_id = :id LIMIT 1');
$stmt->execute(['id' => (int)$_SESSION['user_id']]);
$profileRow = $stmt->fetch(PDO::FETCH_ASSOC) ?: [];
$displayName = trim((string)($profileRow['display_name'] ?? '')) ?: trim((string)($profileRow['first_name'] ?? '')) ?: 'Profil';
$firstChar = mb_substr($displayName, 0, 1);
if ($firstChar !== '') {
$profileInitial = mb_strtoupper($firstChar);
}
}
} catch (\Throwable) {
$displayName = 'Profil';
$profileInitial = 'P';
}
}
?>