prepare("SELECT * FROM products WHERE id = ?"); $stmt->execute([$product_id]); $product = $stmt->fetch(PDO::FETCH_ASSOC); if (!$product) { header('Location: index.php'); exit; } } catch (PDOException $e) { die("Error fetching product: " . $e->getMessage()); } ?>