Page 1 of 1

timed redirect to another URL

Posted: Wed Nov 27, 2002 8:59 am
by Fari
..hi guys .. how can I combine 'header' with a timer to redirect a page after a set time expires? has anyone done anything like this?

ta - Fari

Posted: Wed Nov 27, 2002 9:09 am
by mydimension
do you want to redirect the page after the page has fully loaded? if so, you can't. the php script as finished executing by that time and therefore has no control over the current function of the page (ie. refreshing). you can use the the meta tag to achive this kinda thing.

<meta http-equiv="refresh" content="value [; URL]" />
where value is the number of seconds to wait before refresh and URL, if specified, is the page to refresh to and if not specified, refreshes the current page.

Posted: Wed Nov 27, 2002 9:23 am
by BigE
Yes, you should most likely use the <meta> redirect to do this. However, if your set on using PHP to do this, you can check out sleep() php.net/sleep and header() php.net/header which will accomplish the same thing.

Posted: Sat Jan 25, 2003 2:46 pm
by Kriek
header() refresh/redirect with delay.

Code: Select all

<?php header("refresh: 5; url=http://$SERVER_NAME/page.php"); ?>
header() refresh/re-direct without delay

Code: Select all

<?php header("Location: http://$SERVER_NAME/page.php"); ?>