Hi Sirs,
I do write these codes to redirect to another page ONLY when the point's score is fully 10 for example ($row["total_score"]).
Before to be redirected... just wait certain time (for instance, 5 seconds). After this specific time the page can be redirected. If not the page cannot be redirected to another page. Thank you !
Code
query($sql);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
echo "
";
echo "Total : " . $row["total_score"] . " Point(s)
";
} else {
echo "No results found.";
}
$conn->close();
?>
";
echo "";
}
echo "
";
echo"
";
echo" Partager ou Imprimer ";
echo"
";
echo"
";
?>
Raghunath BhukanRank #744 · 3.1K reputationPosted Jan 10, 2026, 12:15 PM EST
PHP page to wait a few seconds and then redirect only if the score is exactly 10. PHP itself can’t “pause” and then redirect the browser after a delay — the delay has to happen in the browser, which means using JavaScript. PHP can output the JS conditionally based on your score.
Here’s a clean way to do it:
query($sql); if ($result->num_rows > 0) { $row = $result->fetch_assoc(); $totalScore = $row["total_score"]; echo " "; echo ""; echo "Total : " . $totalScore . " Point(s) "; echo " "; // Only redirect if score is exactly 10 if ($totalScore == 10) { echo " // Wait 5 seconds, then redirect setTimeout(function() { window.location.href = 'your_next_page.php'; }, 5000); "; } } else { echo "No results found."; } $conn->close(); ?> Partager ou Imprimer? Explanation:
$totalScorestores the total points.if ($totalScore == 10)ensures the redirect happens only if score is exactly 10.setTimeoutin JavaScript waits 5000 milliseconds (5 seconds) before redirecting.If the score isn’t 10, nothing happens. The page stays as-is.
IsraelRank #1,223 · 1.5K reputationPosted Jan 10, 2026, 4:38 PM EST
@Raghunath B
No comment. The codes are straight on the goal. Thanx !