Noob Noob - 6 months ago 22
PHP Question

php function to refresh page with requested time

So there is a page which needs to refresh as per a user want to.

Now if they want to refresh the page for ten times, what they should do rather than reload the page?

I want something like

xyz.com/abc.php?refresh=10


where
$refresh=[no. of time requested]


How to do that ?

Answer

You can send a Refresh header to tell the page to refresh. Subtract 1 from the number of refreshes so it will count down.

if (isset($_GET['refresh']) && int($_GET['refresh']) > 1) {
    $_GET['refresh']--;
    header("Refresh: $refresh_seconds; {$_GET['refresh']}");
}

where $refresh_seconds is how many seconds it should wait before refreshing.