qwave Posted June 25, 2006 Share Posted June 25, 2006 I basically need to accomplish this feet:repeat header( "Location: page(random number).html ); wait 10 secondsend repeatBasically 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! Quote Link to comment Share on other sites More sharing options...
jajtiii Posted June 25, 2006 Share Posted June 25, 2006 You need javascript to do what you want the most effectively.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 Quote Link to comment Share on other sites More sharing options...
robos99 Posted June 25, 2006 Share Posted June 25, 2006 Something like this might work...instead of pointing to different html pages you could have it keep pointing to the php script and have the page refresh after 10 seconds. Use output buffering to prevent the typical header errors.[code]ob_start();$page=rand();include_once("htmlpage$_GET['page'].html");header("Location: /thisscript.php?page=$page");header("Refresh: 10");ob_end_flush();[/code]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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.