false, 'error' => 'Method not allowed']); exit; } // ── CONFIG ──────────────────────────────────────────────────────────── define('SENDGRID_API_KEY', 'SG.YOUR_KEY_HERE'); // <-- replace with your SendGrid API key define('MAIL_FROM', 'noreply@parkerslingshotrentals.com'); define('MAIL_FROM_NAME', 'Parker County Slingshot Rentals'); define('ADMIN_EMAIL', 'info@parkerslingshotrentals.com'); // where booking alerts go // ───────────────────────────────────────────────────────────────────── $input = json_decode(file_get_contents('php://input'), true); if (!$input) { $input = $_POST; } $name = trim(strip_tags($input['name'] ?? '')); $email = trim(strip_tags($input['email'] ?? '')); $phone = trim(strip_tags($input['phone'] ?? '')); $package = trim(strip_tags($input['package'] ?? '')); $date = trim(strip_tags($input['date'] ?? '')); $message = trim(strip_tags($input['message'] ?? '')); // Basic validation if (!$name || !$email || !$package || !$date) { http_response_code(400); echo json_encode(['success' => false, 'error' => 'Name, email, package, and date are required.']); exit; } if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { http_response_code(400); echo json_encode(['success' => false, 'error' => 'Invalid email address.']); exit; } $packages = [ 'half-day' => 'Half Day (4 hrs) — $99', 'full-day' => 'Full Day (8 hrs) — $169', 'weekend' => 'Weekend (48 hrs) — $299', ]; $packageLabel = $packages[$package] ?? ucfirst($package); $dateFormatted = date('F j, Y', strtotime($date)); // ── SEND ADMIN ALERT ────────────────────────────────────────────────── $adminHtml = '
Parker County Slingshot Rentals
| Name | ' . htmlspecialchars($name) . ' |
| ' . htmlspecialchars($email) . ' | |
| Phone | ' . (htmlspecialchars($phone) ?: 'not provided') . ' |
| Package | ' . htmlspecialchars($packageLabel) . ' |
| Date | ' . htmlspecialchars($dateFormatted) . ' |
' . nl2br(htmlspecialchars($message)) . '
Submitted ' . date('F j, Y \a\t g:i A') . ' CT
Hey ' . htmlspecialchars($name) . ', we got your request and will confirm availability within a few hours.
Package: ' . htmlspecialchars($packageLabel) . '
Requested Date: ' . htmlspecialchars($dateFormatted) . '
We\'ll reach out to you at ' . htmlspecialchars($email) . '' . ($phone ? ' or ' . htmlspecialchars($phone) . '' : '') . ' to confirm your ride.
Questions? Call or text us at (817) 555-0199.
Ride on,
The Parker County Slingshot Team
© ' . date('Y') . ' Parker County Slingshot Rentals — Weatherford, TX