# Email Auto-Capture Setup for Hotel Booking Confirmation

## How It Works

When you send an email campaign through Brevo (or any email platform), the customer clicks a special link that automatically captures their email address. They arrive at the booking page with their email already filled in — no typing needed.

---

## The Two Files

### 1. `landing.php` 
**This is where your email link points to.** It:
- Reads the email from the URL
- Saves it to the visitor's session
- Redirects to st1.php automatically

### 2. `st1.php`
**The booking confirmation page.** It:
- Displays their email in the green confirmation card
- Passes the email to the reservation object (for Google Play or APIs)
- Works with the session to remember their email across pages

---

## Setting Up in Brevo

1. **Go to your campaign email editor**
2. **Find the link to the confirmation page**, or add one:
   - Use this exact URL as your link:
   ```
   https://yourhotelsite.com/ch/hp/landing.php?e={{contact.EMAIL}}
   ```

3. **Replace `yourhotelsite.com` with your actual domain**

4. **How it works:**
   - Brevo swaps `{{contact.EMAIL}}` with each recipient's real email
   - Bob gets: `...landing.php?e=bob@example.com`
   - Sara gets: `...landing.php?e=sara@example.com`
   - Each person only sees their own email

---

## Professional Display

The email appears in two places:

1. **In the green confirmation card** - shows their email professionally
2. **In the JavaScript `reservation` object** - for sending to Google Play or other systems

---

## Important Notes

- ✅ The email is **never shown in the URL** after landing.php — it gets hidden immediately
- ✅ The email works across the entire session — not just st1.php
- ✅ If someone arrives without an email link, nothing breaks (the card just won't show the email)
- ⚠️ The `+` symbol in emails like `bob+shop@example.com` is automatically fixed

---

## Testing

1. Test locally:
   ```
   php -S localhost:8000 -t .
   ```
   
2. Visit: `http://localhost:8000/landing.php?e=test@example.com`

3. You should be redirected to st1.php and see the email in the green card.

---

## Next Steps

Once this is live on your server:

1. Copy the landing.php link above
2. Paste it into your Brevo campaign
3. Send a test email to yourself
4. Click the link and verify the email appears
