Multiple header() calls in a row, possible?
Posted 25 June 2006 - 01:48 AM
header( "Location: page(random number).html );
wait 10 seconds
Basically I want to write a script that iterates over and over again, changing the browser window to a different page each time. Sort of like an automatic 'tour' of a website. What method should I use to accomplish this? Can the PHP script still run even after the page header has changed?
This doesnt seem to work:
header( "Location: blah1.html );
sleep( 5 );
header( "Location: blah2.html );
As only blah2.html page loads. For some reason, even though blah1.html is told to load first, the code completely skips it and moves to blah2.html instead after 5 seconds.
Thanks in advance!
Posted 25 June 2006 - 02:55 AM
You can build an onload function that will wait 5 seconds before querying the server for another random page.
You really cannot do this with PHP. It is a server side script. All logic/functions done in PHP are executed on the server before it sends you the results.
For example, 'header()' is executed on the server. When the html hits your browser, the server is done executing your script.
hope that makes sense
Posted 25 June 2006 - 03:03 AM
ob_start(); $page=rand(); include_once("htmlpage$_GET['page'].html"); header("Location: /thisscript.php?page=$page"); header("Refresh: 10"); ob_end_flush();
This is just off the top of my head...it may not work, or there may be a better solution. But it's an idea.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users