Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 8 of 8

Thread: Refresh page

  1. #1
    Senior Member Eddy Bones's Avatar
    Join Date
    Jan 2004
    Location
    Washington, USA
    Posts
    1,054
    Member #
    4651
    Is there a way to refresh the page using PHP or would I need to put in a Javascript function to do so? If so, may I have an example of the code? I haven't used Javascript very much.

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    You'd probably need Javascript. If you need to refresh it after a certain amount of seconds, actually, you can use an HTML META refresh; namely:
    Code:
    <meta http-equiv="refresh" content="5;uri.html" />
    Where 5 is the number of seconds to wait and uri.html is the location to go to. Since in your case, it is the same page, you can simply leave off the URI and make it `content="5"'

    If you wanted, say, a link to reload the page, however, you would do something like this:
    Code:
    <a href="javascript:window.location.refresh(false);">TEXT</a>
    You can switch the `false' in the function call to `true' if the contents are expected to have changed.

  4. #3
    Senior Member Eddy Bones's Avatar
    Join Date
    Jan 2004
    Location
    Washington, USA
    Posts
    1,054
    Member #
    4651
    What if I wanted the page to refresh at the end of a section of PHP code? (Sorry, I should have said that before.) Perhaps at the end of an if statement. Would I still be able to use JS somehow?

  5. #4
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    sure, easy.

    PHP Code:
    header("Location:samepage.php"); 
    Redirecting to the same page is the same as refreshing Though, seems like this would create a bit of an infinate loop...
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  6. #5
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Yes, what Brak said. The way to avoid an infinite loop would be to make sure it's in some sort of if statement so that it only gets executed in very specific circumstances.

  7. #6
    Senior Member Eddy Bones's Avatar
    Join Date
    Jan 2004
    Location
    Washington, USA
    Posts
    1,054
    Member #
    4651
    Yes, that would work. I'm trying to remember why I thought it wouldn't...

    It's for a style switcher, in case you were wondering.

    Another question. When you log into forums it usually give a login confirmation page ("Thanks for loging in, username"), and automatically redirects to the main page after 5 seconds or so. How would you put a delay on it like that?

  8. #7
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    That one is a META refresh, see what I posted above.

  9. #8
    Senior Member Eddy Bones's Avatar
    Join Date
    Jan 2004
    Location
    Washington, USA
    Posts
    1,054
    Member #
    4651
    Thanks for the help. Much appreciated.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:07 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com