Reputation: 111
I have a search function on my web page and want to force form re-submission when the user presses the back button.
Here is the flow of information...
Search Page > Display Results Page > Product Page
Currently when a user is on the Product Page and presses the back button, they receive the following error on the Display Results Page (Chrome): "Confirm Form Resubmission ERR_CACHE_MISS"
I would like the page to resubmit the form automatically so the user's original search results are displayed on the Display Results Page.
Preferably I would like to do this without using $_GET, if at all possible.
edit: The following code did not work.
if(isset($_POST['query'])) {
$_SESSION['query'] = $_POST['query'];
}
else {
$_POST['query'] = $_SESSION['query'];
}
Upvotes: 1
Views: 1283
Reputation: 111
I found the following answer and working code - this seems like the path of least resistance to me. This code should go on the "display results" page for anyone having the same issue.
header('Cache-Control: no cache');
session_cache_limiter('private_no_expire');
session_start();
Upvotes: 2
Reputation: 711
Save the input value to a session so when the user presses back, the value is still there and use ajax/jquery to populate the result page.
Upvotes: 0