prepare("SELECT id FROM restaurants WHERE id = ? AND user_id = ?"); $stmt->execute([$restaurant_id, $_SESSION['user_id']]); if (!$stmt->fetch()) { die('You do not have permission to add items to this restaurant.'); } try { $stmt_insert = $pdo->prepare( "INSERT INTO menu_items (restaurant_id, name, description, price) VALUES (?, ?, ?, ?)" ); $stmt_insert->execute([$restaurant_id, $item_name, $item_description, $item_price]); // Redirect back to the dashboard header("Location: dashboard.php?item_added=success"); exit(); } catch (PDOException $e) { // In a real app, you would log this error die("Error adding menu item: " . $e->getMessage()); }