prepare("SELECT * FROM orders WHERE id = ? AND user_id = ?"); $stmt->execute([$order_id, $user_id]); $order = $stmt->fetch(PDO::FETCH_ASSOC); } elseif ($guest_token) { $stmt = $pdo->prepare("SELECT * FROM orders WHERE id = ? AND token = ?"); $stmt->execute([$order_id, $guest_token]); $order = $stmt->fetch(PDO::FETCH_ASSOC); } if (!$order) { // If the order is not found or doesn't belong to the user/guest, redirect. header("Location: index.php"); exit(); } // Fetch order items $itemsStmt = $pdo->prepare(" SELECT oi.quantity, mi.name, mi.price, mi.restaurant_id FROM order_items oi JOIN menu_items mi ON oi.menu_item_id = mi.id WHERE oi.order_id = :order_id "); $itemsStmt->bindParam(':order_id', $order_id); $itemsStmt->execute(); $orderItems = $itemsStmt->fetchAll(PDO::FETCH_ASSOC); // Determine the correct tracking URL $tracking_url = "order_status.php?order_id=" . $order_id; if (!$user_id && $guest_token) { $tracking_url .= "&token=" . $guest_token; } include 'header.php'; ?>
Your order has been placed successfully.
Your Order ID is:
Name:
Address:
Phone:
Date:
Status:
We've received your order and will begin processing it shortly. You can track the progress of your order using the button below.
Continue Shopping Track Order Leave a Review