39498-vm/book_offer.php
2026-04-06 05:35:15 +00:00

25 lines
542 B
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/app.php';
ensure_schema();
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
header('Location: /');
exit;
}
$requestId = filter_input(INPUT_POST, 'request_id', FILTER_VALIDATE_INT);
$offerSlug = trim((string) ($_POST['offer_slug'] ?? ''));
if (!$requestId || $offerSlug === '' || !offer_by_slug($offerSlug)) {
header('Location: /requests.php');
exit;
}
book_offer($requestId, $offerSlug);
header('Location: /request_success.php?id=' . $requestId . '&booked=1');
exit;