[PHP] Wait for a while then redirect

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by Shadow121, Feb 16, 2008.

  1. Shadow121

    Shadow121 Member

    Messages:
    901
    Likes Received:
    0
    Trophy Points:
    16
    I'm working on a new site in which i want a function that will wait x amount of time defined in hte calling of it then print the redirect script.

    Any suggestions on how?
     
  2. Xemnas

    Xemnas New Member

    Messages:
    812
    Likes Received:
    0
    Trophy Points:
    0
    You should be able to do this with sleep(); the parameter for it is an integer representing the number of seconds you want to delay script execution.

    Alternatively, you can just use this line of HTML code:
    HTML:
    <meta http-equiv='refresh' content='[seconds];URL=main.php'>
     
    Last edited: Feb 16, 2008
  3. Shadow121

    Shadow121 Member

    Messages:
    901
    Likes Received:
    0
    Trophy Points:
    16
    Okay, i'll try that.
    Edit: That works thanks ^^

    Edit 2: I've done that in the past but this time i'm going to keep it XHTML Valid.
     
    Last edited: Feb 16, 2008
  4. marshian

    marshian New Member

    Messages:
    526
    Likes Received:
    9
    Trophy Points:
    0
    You wanted a php script, not a meta refresh :p
    here's what you want:
    PHP:
    $time 3//Time (in seconds) to wait.
    $url "http://www.google.be"//Location to send to.
    header("Refresh: $time; url=$url");
     

Share This Page