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'] ?? ''; if ($name && $price) { $stmt = $pdo->prepare("INSERT INTO menu_items (restaurant_id, name, description, price) VALUES (?, ?, ?, ?)"); $stmt->execute([$restaurant_id, $name, $description, $price]); header('Location: menu.php'); exit; } else { $error = "Name and price are required."; } } ?>

Add New Menu Item

Cancel