When the user submits a form on my site, and then upon the new page's loading, hits the back button, he gets the message "The page you are trying to view contains POSTDATA that has expired from the cache. If you resend the data etc. etc."
How do I stop this message from appearing? I do not want to resubmit the data when the user navigates backwards, and I do not need to show the data in the form.
Searching around, I found some advice which says:
add this to the top of the form page -
<?php
session_start();
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?>
but for some reason I still get the POSTDATA expired message. Is this bad advice or maybe something more is required?
Searching further, I found this also:
after processing a POST request, use a redirect to send the browser to the results page. The browser will issue a GET request for the result page (and when the user clicks the back button, they will see the results of their earlier submission).
Here's an example from a PHP site I maintain. The POSTed form is processed, and the browser is redirected to issue a GET request for a 'thankyou' page.
//start of PHP form handler
<?
// process the form fields...
$email = $_REQUEST['email'] ;
// etc etc
// ...then finally
header("Location: http://www.somewhereelse.co.uk/formhandling/thankyou.html");
?>
//EOF
is this a good solution?
Ideally I want my page to work like vbulletin when you click 'back' after making a post: you don't get the POSTDATA message, and the form doesn't resubmit the POST data either.
Thanks for your help!