1

I want to create an application in PHP.

concept is very simple, I want to just auto load every page randomly at a regular intervals. For example, if I entered to facebook.com, it would be auto load randomly profile.php, notifications.php, messages.php etc... I am not sure about its practicality. So my question may be stupid, but I need help. I only know meta refresh which is only for refreshing the page.

<meta http-equiv="refresh" content="5; url=http://example.com/">

But I think, using the loop , My concept will work. But I have no idea how loop will work with meta tag.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Kiran RS
  • 981
  • 14
  • 31
  • Your question is very broad. You aren't showing any code, and your question does not make sense. Think about it, after four hours, none of the solutions provided have anything to do with the question at hand. That tells me that the question is too broad. – Justin E Dec 19 '13 at 16:42
  • @ Justin E- do you think the persons who gave me upvotes are fools? – Kiran RS Dec 20 '13 at 04:52
  • @OP please review my updated answer, then remove your down vote as I have. – Justin E Dec 20 '13 at 14:10
  • @Justin E- i am not downvoted in your answer. – Kiran RS Dec 20 '13 at 15:50

3 Answers3

1

Looking strange requirement, anyhow, you can use

sleep(5)

function after your page get loads in a recursive way.. you should read this..

Irfan Ahmed
  • 9,136
  • 8
  • 33
  • 54
0

The below code will redirect you to the appropriate page. You could check the time stamp, and if it is so much different than the initial page load timestamp, execute the header commmand. You really would be better off using meta in this case.

Header('Location: http://www.google.com');

TrY:

while(1=1){
    sleep(5);

    //Use one of the following methods to refresh.
    echo "<meta http-equiv=\"refresh\" content=\"5; url=/profile.php?pid=".$profile_id."\">";
    Header('Location: /profile.php?pid='.$profile_id);
    echo "<script>javascript:window.href.replace('/profile.php?pid=".$profile_id."');";
}

also review: Server Sent Events

Justin E
  • 1,252
  • 16
  • 30
  • Please tell me what explanation do you need? – Kiran RS Dec 19 '13 at 16:33
  • @KiranRS please see comment above. – Justin E Dec 19 '13 at 16:46
  • @ Justin E- I know this concept is very strange , so that I've explained an example of facebook in my question.Read that and now tell me what explanation do you need other than this. – Kiran RS Dec 20 '13 at 04:58
  • Okay, so you want to refresh a page every x amount of seconds? Look into [Ajax Listening](http://api.jquery.com/Ajax_Events/) because refreshing the page like that uses a lot of excess bandwidth. You can also use a div and use Ajax to refresh the div every x amount of seconds. – Justin E Dec 20 '13 at 14:06
  • NOT REFRESHING, my concept is redirect to another pages randomly with in a webpage. BUT I REALY APPRECIATE YOUR EFFORT. Me too come to this concept(SSE) frequently , but i am totaly confuse with my idea, which one wil accept.... – Kiran RS Dec 20 '13 at 16:03
  • Facebook does not redirect randomly. You could list the pages that you could redirect to, then do `Header('Location: '.array_rand($redirect_to_array);` – Justin E Dec 20 '13 at 16:09
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/43609/discussion-between-kiran-rs-and-justin-e) – Kiran RS Dec 20 '13 at 16:12
0

I finally got the soloution,

<script>
  var interval = 5; // in seconds
  var pages = [
    'http://website.com/link1.php',
    'http://website.com/link2.php',
    'http://website.com/link3.php'
  ];
  var current_page_index = 0;

  setInterval(function() {
    loadintoIframe('myframe', pages[current_page_index]);
    current_page_index = (current_page_index + 1) % pages.length;
  }, interval * 1000); // second setInterval param is milliseconds
</script>
Kiran RS
  • 981
  • 14
  • 31