= 1 && $rating <= 5 && $review_text) { $stmt = $db->prepare("INSERT INTO reviews (product_id, user_id, name, email, rating, title, review, status) VALUES (?, ?, ?, ?, ?, ?, ?, 0)"); $stmt->execute([$product_id, $_SESSION['user_id'], $user['first_name'] . ' ' . $user['last_name'], $user['email'], $rating, $title, $review_text]); set_flash('success', 'Thank you! Your review is awaiting approval.'); } $product = $db->prepare("SELECT slug FROM products WHERE id = ?"); $product->execute([$product_id]); $product = $product->fetch(); if ($product) { header('Location: ' . SITE_URL . 'pages/product.php?slug=' . $product['slug']); } else { header('Location: ' . SITE_URL); } exit;