diff --git a/index.php b/index.php index 7205f3d..3097c94 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,234 @@ prepare("SELECT * FROM guests WHERE id = ?"); + $stmt->execute([$_SESSION['guest_id']]); + $guest = $stmt->fetch(PDO::FETCH_ASSOC); +} + +// Handle form submissions +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $pdo = db(); + if (isset($_POST['email'])) { + // Email check + $stmt = $pdo->prepare("SELECT * FROM guests WHERE email = ?"); + $stmt->execute([$_POST['email']]); + $guest = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($guest) { + $_SESSION['guest_id'] = $guest['id']; + } else { + $error_message = "Désolé, votre email n'a pas été trouvé. Veuillez vérifier l'adresse ou nous contacter."; + } + } elseif (isset($_POST['update_rsvp']) && $guest) { + // RSVP update + $person_count = isset($_POST['person_count']) ? intval($_POST['person_count']) : 1; + + foreach ($_POST['events'] as $event_id => $status) { + $stmt = $pdo->prepare("UPDATE invitations SET attending = ? WHERE guest_id = ? AND event_id = ?"); + $stmt->execute([$status === 'yes' ? 1 : 0, $guest['id'], $event_id]); + } + + // This is a simplified update for person_count, assuming it applies to all 'yes' responses. + $stmt = $pdo->prepare("UPDATE invitations SET person_count = ? WHERE guest_id = ? AND attending = 1"); + $stmt->execute([$person_count, $guest['id']]); + + $success_message = "Merci ! Votre réponse a été enregistrée."; + // Refresh guest data to show updated status + $stmt = $pdo->prepare("SELECT * FROM guests WHERE id = ?"); + $stmt->execute([$guest['id']]); + $guest = $stmt->fetch(PDO::FETCH_ASSOC); + } +} + +// If a guest is identified, fetch their invitations +if ($guest) { + $pdo = db(); + $stmt = $pdo->prepare(" + SELECT e.id, e.name, i.attending, i.person_count + FROM invitations i + JOIN events e ON i.event_id = e.id + WHERE i.guest_id = ? + ORDER BY e.id + "); + $stmt->execute([$guest['id']]); + $events = $stmt->fetchAll(PDO::FETCH_ASSOC); +} ?> - - + + - - - New Style - - - - - - - - - - - - - - - - - - - + + + Mariage de J & M + + + + + + + + + + + + + + + + + + "> + -
-
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

-
-
- + + + + +
+ Illustration florale +

Mélanie & Cyprien

+
+ + +
+ +
+
+

Informations Pratiques

+
+
+

Cérémonie

+

15h00 - Mairie de Quelque Part

+

Adresse, 12345 Ville

+
+
+

Réception

+

18h00 - Domaine de Rêve

+

Adresse, 12345 Ville

+
+
+
+
+ + +
+
+

Le Programme

+

Le déroulé de notre journée.

+ +
+
+ + +
+
+

RSVP

+
+
+ +
+ + +
+ + + + +

Veuillez confirmer votre présence avant le 1er mai 2026.

+
+
+ + +
+
+ +
+
+ + +
+

Bonjour, !

+

Nous sommes ravis de vous inviter aux événements suivants. Merci de nous donner votre réponse pour chacun.

+

Ce n'est pas vous ?

+
+ +
+ + + +
+
+
+ required> + +
+
+ required> + +
+
+ + +
+ + +
+ +
+ +
+
+ + +
+
+
+
+
+ + + + + + + + - + \ No newline at end of file