pdo(); $flash = $app->flash()->get(); $userId = (int)$_SESSION['user_id']; $error = ''; $info = ''; // POST Aktionen if ($_SERVER['REQUEST_METHOD'] === 'POST') { $action = $_POST['action'] ?? ''; try { if ($action === 'profile') { $stmt = $pdo->prepare('UPDATE user_profiles SET display_name=:name, zip=:zip, city=:city, profession=:prof, languages=:langs, about=:about, updated_at=NOW() WHERE user_id=:id'); $stmt->execute([ 'name' => trim((string)$_POST['display_name']), 'zip' => trim((string)$_POST['zip']), 'city' => trim((string)$_POST['city']), 'prof' => trim((string)$_POST['profession']), 'langs' => trim((string)$_POST['languages']), 'about' => trim((string)$_POST['about']), 'id' => $userId, ]); $info = 'Profil gespeichert.'; } elseif ($action === 'child_add') { $stmt = $pdo->prepare('INSERT INTO children (user_id, gender, birthdate, age_years, encrypted_first_name, note, created_at, updated_at) VALUES (:uid, :gender, :birthdate, :age, :name, :note, NOW(), NOW())'); $stmt->execute([ 'uid' => $userId, 'gender' => $_POST['gender'] ?? 'unknown', 'birthdate' => $_POST['birthdate'] ?: null, 'age' => $_POST['age_years'] ?: null, 'name' => trim((string)$_POST['first_name']), 'note' => trim((string)$_POST['note']), ]); $info = 'Kind hinzugefügt.'; } elseif ($action === 'event_add') { $stmt = $pdo->prepare('INSERT INTO events (created_by, title, teaser_public, description, location_label, zip, city, region, lat, lng, starts_at, allow_kids, visibility, status, created_at, updated_at) VALUES (:uid, :title, :teaser, :descr, :loc, :zip, :city, :region, NULL, NULL, :start, :allow, :vis, :status, NOW(), NOW())'); $stmt->execute([ 'uid' => $userId, 'title' => trim((string)$_POST['title']), 'teaser' => trim((string)$_POST['teaser']), 'descr' => trim((string)$_POST['description']), 'loc' => trim((string)$_POST['location_label']), 'zip' => trim((string)$_POST['zip']), 'city' => trim((string)$_POST['city']), 'region' => trim((string)$_POST['region']), 'start' => $_POST['starts_at'] ?? null, 'allow' => isset($_POST['allow_kids']) ? 1 : 0, 'vis' => $_POST['visibility'] ?? 'public', 'status' => 'published', ]); $info = 'Event gespeichert.'; } } catch (Throwable $e) { $error = $e->getMessage(); } } // Daten laden $profile = [ 'display_name' => '', 'zip' => '', 'city' => '', 'profession' => '', 'languages' => '', 'about' => '', ]; $stmt = $pdo->prepare('SELECT u.email, u.status, p.display_name, p.zip, p.city, p.profession, p.languages, p.about FROM users u LEFT JOIN user_profiles p ON p.user_id = u.id WHERE u.id = :id LIMIT 1'); $stmt->execute(['id' => $userId]); $row = $stmt->fetch(PDO::FETCH_ASSOC); if ($row) { $profile = array_merge($profile, array_filter($row, fn($v) => $v !== null)); } $children = []; $stmt = $pdo->prepare('SELECT id, encrypted_first_name AS first_name, gender, birthdate, age_years FROM children WHERE user_id = :id ORDER BY id DESC'); $stmt->execute(['id' => $userId]); $children = $stmt->fetchAll(PDO::FETCH_ASSOC) ?: []; $events = []; $stmt = $pdo->prepare('SELECT id, title, teaser_public, starts_at, city, visibility FROM events WHERE created_by = :id ORDER BY starts_at DESC'); $stmt->execute(['id' => $userId]); $events = $stmt->fetchAll(PDO::FETCH_ASSOC) ?: []; ?>

Mitgliederbereich

Hallo, !

Verwalte dein Profil, Kinder, Events und Teilnahmen.

Fehler:
Profil

Deine Angaben

Kinder

Deine Kids

Noch keine Kinder eingetragen.

  • ,
Deine Events

Noch keine Events angelegt.

  • , ()
Eigenes Event

Neuen Termin erstellen