Need Help: Form submit and IE Back button problem !!!

Discussion in 'HTML & Website Design' started by cuongdm, Oct 17, 2006.

  1. #1
    Hi guys,

    My problem is when I submit my form and use the IE Back button, I got the error message "The page can not be displayed...."
    below is how I do with the form

    The First:
    1. Page 1: submit form, method = post, action = Page 2
    2. Page 2: process the form data and redirect (header/javascript) to Page 3
    3. Page 3: hit the IE Back button and get the error

    The Second:
    1. Page 1: submit form, method = post, action = Page 2
    2. Page 2: process the form data and stay in Page 2
    3a. Page 2: hit the IE Back button, working properly
    ---------------------
    3b. Page 2: click a hyperlink to page 3
    4. Page 3: hit the IE Back button and get the error

    I don't know why I get this error and how to solve....
    need your help!
     
    cuongdm, Oct 17, 2006 IP
  2. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Its because the page contains expired post data and showing the page would mean resending the data. Your redirect is probably not being done properly otherwise the page 2 which contains postdata would not be cached.

    In your scenario 1 you should send a HTTP 303 response code from page 2 to indicate that the intermediate page must not be cached. Also, don't send any actual output (no page contents, meaning no Javascript either).

    header('HTTP/1.1 303 See Other');
    header('Location: http://example.com/page3');
    
    Code (PHP):
    Adapt to your particular language as required.
     
    penagate, Oct 17, 2006 IP
  3. cuongdm

    cuongdm Peon

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I just do a little test and what i want to say is: THANK YOU SO MUCH penagate !!!
    1. I use PHP to code
    2. Insert ob_start() at the beginning and ob_end_flush() at the end to avoid sending output (so, i can make sure that the redirect function always uses php header)
    3. add your code header('http/1.1 303 see other');
    4. add exit; after header('location : $page');
    5. working so coooool
    ============
    again, thank you penagate! :)
     
    cuongdm, Oct 17, 2006 IP