prepare("SELECT id, name, email, booking_ref, rental_date, status FROM bookings WHERE booking_ref=?"); $stmt->execute([$ref]); $booking = $stmt->fetch(); if (!$booking) $error = 'Booking not found. Please check your confirmation email.'; elseif ($booking['status'] === 'cancelled') $error = 'This booking has been cancelled.'; } if ($_SERVER['REQUEST_METHOD'] === 'POST' && $booking && !$error) { $file = $_FILES['doc'] ?? null; if (!$file || $file['error'] !== UPLOAD_ERR_OK) { $error = 'Upload failed — please try again or check file size.'; } else { $finfo = new finfo(FILEINFO_MIME_TYPE); $mime = $finfo->file($file['tmp_name']); $allowed = ['image/jpeg','image/png','application/pdf']; if (!in_array($mime, $allowed)) { $error = 'Only JPG, PNG, or PDF files are accepted.'; } elseif ($file['size'] > 10 * 1024 * 1024) { $error = 'File must be under 10 MB.'; } else { $ext = ['image/jpeg'=>'jpg','image/png'=>'png','application/pdf'=>'pdf'][$mime]; $dir = __DIR__ . '/uploads/' . $ref; if (!is_dir($dir)) mkdir($dir, 0750, true); $fname = $type . '_' . date('YmdHis') . '.' . $ext; $dest = $dir . '/' . $fname; if (move_uploaded_file($file['tmp_name'], $dest)) { $col = $type === 'license' ? 'license_file' : 'insurance_file'; $rel = 'uploads/' . $ref . '/' . $fname; db()->prepare("UPDATE bookings SET {$col}=? WHERE booking_ref=?")->execute([$rel, $ref]); $typeLabel = $type === 'license' ? "Driver's License" : 'Proof of Insurance'; $dateLabel = date('F j, Y', strtotime($booking['rental_date'])); $adminHtml = "
" . htmlspecialchars($booking['name']) . " uploaded their {$typeLabel} for booking {$booking['booking_ref']} (rental: {$dateLabel}).
View it in the admin panel under their booking detail.
Invalid or missing upload link. Please use the link from your email or contact us.
Need help? Call or text (817) 266-2022.
Thanks, = htmlspecialchars($booking['name']) ?>! Your = htmlspecialchars($typeLabel) ?> has been submitted for booking = htmlspecialchars($booking['booking_ref']) ?>.
We'll review it and still do a quick visual check at pickup. See you on = htmlspecialchars($dateLabel) ?>!
Please upload a photo or scan of your current auto insurance card. JPG, PNG, or PDF accepted (max 10 MB). Please upload a photo or scan of the front of your driver's license. JPG, PNG, or PDF accepted (max 10 MB).
We'll still do a visual check at pickup — this is just for our records.
Your document is stored securely and only visible to Parker County Slingshot Rentals staff.