prepare("SELECT * FROM tour_packages WHERE id = ?"); $stmt->execute([$id]); $tour = $stmt->fetch(PDO::FETCH_ASSOC); if (!$tour) { header('Location: admin_tours.php?error=notfound'); exit; } $name = $tour['name']; $destination = $tour['destination']; $duration_days = $tour['duration_days']; $price = $tour['price']; $description = $tour['description']; } catch (PDOException $e) { $errors[] = "Database error: " . $e->getMessage(); } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $name = trim($_POST['name'] ?? ''); $destination = trim($_POST['destination'] ?? ''); $duration_days = trim($_POST['duration_days'] ?? ''); $price = trim($_POST['price'] ?? ''); $description = trim($_POST['description'] ?? ''); if (empty($name)) { $errors[] = 'Package name is required.'; } if (empty($destination)) { $errors[] = 'Destination is required.'; } if (!filter_var($duration_days, FILTER_VALIDATE_INT, ["options" => ["min_range" => 1]])) { $errors[] = 'Duration must be a positive number.'; } if (!filter_var($price, FILTER_VALIDATE_INT, ["options" => ["min_range" => 0]])) { $errors[] = 'Price must be a non-negative number.'; } if (empty($errors)) { try { $sql = "UPDATE tour_packages SET name = ?, destination = ?, duration_days = ?, price = ?, description = ? WHERE id = ?"; $stmt = $pdo->prepare($sql); $stmt->execute([$name, $destination, $duration_days, $price, $description, $id]); header("Location: admin_tours.php?success=2"); exit; } catch (PDOException $e) { $errors[] = "Database error: " . $e->getMessage(); } } } require_once 'includes/admin_sidebar.php'; ?>

Edit Tour Package

Update the details for the tour package below.

Tour Package Details


Cancel