SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Avoiding : Page Refresh using Back Button

    Hello folks. I read somewhere how I can avoid getting the 'reload page since content has expired' screen after someone presses 'back' after sending a FORM.

    Though for the life of me I can't remember where I read it, nor the exact way of doing it, bar the fact that you had to redirect to another page or something.

    Does anyone know of a solution to this problem I wonder ?

  2. #2
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, if you don't want the user to be able to go back to the POSTed page, you could redirect to a different page after doing your processing in the POSTed file.

    now, if you wanted them to be able to go back to the page, but have it automatically refresh without the "expired" message, that's a browser issue and i don't think you can really change it from PHP.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  3. #3
    SitePoint Evangelist TRISPECTIVE's Avatar
    Join Date
    Sep 2002
    Location
    n/a
    Posts
    477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  4. #4
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks folks for the help - trispective; first link doesn't exist btw but thanks anyways.

    From what I can remember, once the $_POST data has been sent, and dealt with, you re-direct to another page outside the FORM.

    So if you press BACK or REFRESH the data is not sent since the FORM (after originally being redirected) doesn't exist.

    I cannot remember the exact mechanics behind it, though it worked on various browsers on Win98SE and Win2000Pro. 8)

    Once I've the time, I'll have another bash at it and get back to this post later.

  5. #5
    SitePoint Evangelist TRISPECTIVE's Avatar
    Join Date
    Sep 2002
    Location
    n/a
    Posts
    477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston
    Thanks folks for the help - trispective; first link doesn't exist btw but thanks anyways.
    I used the quick reply and it seems it has messed the URL. The URL was:
    http://www.webhistory.org/www.lists/...95q2/0440.html



    Quote Originally Posted by Dr Livingston
    From what I can remember, once the $_POST data has been sent, and dealt with, you re-direct to another page outside the FORM.
    Also, if all you need is to refresh the page or redirect users to another page like they automaticly go to another URL after a page is loaded, use the PHP function header()
    or
    the meta tag:
    <META HTTP-EQUIV="refresh" CONTENT="0; URL=http://yoururl.com">

    I hope that is what you are were looking for.

  6. #6
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, to redirect after headers have been sent I usually use Javascript for this - no markup - but from what I've been reading is this;

    Once you've sent a FORM you need to redirect to a new page, thus if the user refreshes the page, it'll refresh the redirected page and not the one with the FORM on it.

    But in my case, I have validation to take care of as well, and all this is through XML/XSL. LoL

    Yes, what fun. Not. If I redirect and there is bad input from user, I need to redirect back to the page with the FORM, and most likely loose any correct data the user did input. LoL.

  7. #7
    jigga jigga what? slider's Avatar
    Join Date
    Oct 2002
    Location
    Utah (USA)
    Posts
    309
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Validate the data before you redirect, that way you can send a browser 'BACK' command with JS rather than the redirect. This should keep the form fields all filled in for their second attempt to fill it out right. Guess you couldn't include a message that told them what was wrong very easily that way though.
    $slider = 'n00b';


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •