prepare("SELECT id FROM restaurants WHERE user_id = ?"); $stmt->execute([$_SESSION['user_id']]); $restaurant = $stmt->fetch(); if (!$restaurant) { header('Location: ../index.php'); exit; } $restaurant_id = $restaurant['id']; // Get the menu item and verify it belongs to the correct restaurant $stmt = $pdo->prepare("SELECT * FROM menu_items WHERE id = ? AND restaurant_id = ?"); $stmt->execute([$menu_item_id, $restaurant_id]); $item = $stmt->fetch(); if (!$item) { // If the item doesn't exist or doesn't belong to this owner, redirect header('Location: menu.php'); exit; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $name = $_POST['name'] ?? ''; $description = $_POST['description'] ?? ''; $price = $_POST['price'] ?? ''; if ($name && $price) { $stmt = $pdo->prepare("UPDATE menu_items SET name = ?, description = ?, price = ? WHERE id = ? AND restaurant_id = ?"); $stmt->execute([$name, $description, $price, $menu_item_id, $restaurant_id]); header('Location: menu.php'); exit; } else { $error = "Name and price are required."; } } ?>

Edit Menu Item

Cancel