prepare("SELECT id FROM restaurants WHERE user_id = ?"); $stmt->execute([$_SESSION['user_id']]); $restaurant = $stmt->fetch(); if (!$restaurant) { // If for some reason the user is a restaurant owner but has no restaurant, redirect them header('Location: ../index.php'); exit; } $restaurant_id = $restaurant['id']; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $name = $_POST['name'] ?? ''; $description = $_POST['description'] ?? ''; $price = $_POST['price'] ?? ''; $promotion_id = $_POST['promotion_id'] ?? null; if ($name && $price) { $stmt = $pdo->prepare("INSERT INTO menu_items (restaurant_id, name, description, price, promotion_id) VALUES (?, ?, ?, ?, ?)"); $stmt->execute([$restaurant_id, $name, $description, $price, $promotion_id]); header('Location: menu.php'); exit; } else { $error = "Name and price are required."; } } $stmt = $pdo->prepare("SELECT * FROM special_promotions"); $stmt->execute(); $promotions = $stmt->fetchAll(); ?>

Add New Menu Item

Cancel