Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2012
    Posts
    47
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Form fields continue to display data when back button is used

    I have a web form that itself is included as part of a main page.
    When the form successfully submits an included confirmation page
    replaces the form page.
    However if I click the browser back button while on the confirmation
    page all of the form fields are filled in as they were when the form was
    submitted.
    I have tried lots of fixes suggested on the web such as
    PHP Code:
    header("Location:index.php?sendto=sendto";
    $_POST = array();
    exit; 
    However although the header redirect is ideally going to another page, because
    the redirect is still part of the main page the browser does not clear the form
    when the back button is used.
    Also when the back button is clicked if I click the refresh page button the fields
    are instantly cleared.
    So it looks like I need to detect when the back button is clicked and the trigger a refresh.

  2. #2
    Regular Coder Vege's Avatar
    Join Date
    Jan 2008
    Posts
    986
    Thanks
    22
    Thanked 134 Times in 133 Posts
    Add
    PHP Code:
    <?php
    header
    ("Cache-Control: no-store");
    on the page that has the form. This way it will never be cached by the browser.


 

Tags for this Thread

Posting Permissions

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