SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Enthusiast Cheezewiz's Avatar
    Join Date
    May 2003
    Location
    Somewhere East of Valinor
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reset $_POST data - How to?

    I have a problem with POST messages. I use POST in a form on one page of my site, and then when I go to another page, if I hit the back button, I get a message telling me that I will lose the POST data. Using GET does away with this problem, but I do not want to have the data in the URL, so POST is my preferred method of entering the data from the form. Is there a way to clear the $_POST array after I use the data, so this message will not be triggered that does not put a [RESET] button on the page? I am trying to do everything with PHP & simple HTML4 that works on all browsers, so I am not using any other scripts.

    Thanks,

    Mike

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    After you have processed the form data make your page redirect to another page using the "Location" header command ...
    PHP Code:
    // Process the form data then
    header ("Location: some_other_page.php"); 
    This will stop the user going back to the form and seeing the Refresh message.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Enthusiast Cheezewiz's Avatar
    Join Date
    May 2003
    Location
    Somewhere East of Valinor
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks.

    A question... I previously tried using header(location.x) to force opening a new page and got an error message unless I put it in the header section of my page. How do I execute this function after I process the data?

    Mike

  4. #4
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    As long as the form processing does not cause anything to be echo'ed to the browser then there is no problem. One way to to this is to set your <form> action attribute to, say, form_process.php which does nothing but process the form. Once complete it then uses the header() to go to a thank you page or whatever.

    The key is to have all the processing and the header() function before even your <html> tag.
    Ian Anderson
    www.siteguru.co.uk

  5. #5
    SitePoint Enthusiast Cheezewiz's Avatar
    Join Date
    May 2003
    Location
    Somewhere East of Valinor
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I'll try that.

    Mike


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
  •