Reputation: 3214
The problem i'm having is i keep on having to delete the cache or the form doesn't submit anything new. For example i typed in new data in the form and submitted and it wasn't inserted into mysql. I have to delete the cache first.
On submit.php
is a form. done.php
recieves $_POST
variables from submit.php
. At the top of done.php
i have session_cache_limiter('private_no_expire');
. I have this so when the user presses the back button and returns to done.php
, they won't get the page expired message.
I only added session_cache_limiter('private_no_expire');
to get rid of the page expired message. Is there alternative so when i user presses the back button they don't get the page expired message?... alternatively how do i solve this?
Upvotes: 0
Views: 1399
Reputation: 69967
One alternative is to send a 301 redirect from the form processor back to submit.php after a failed or successful submission. This will prevent the prompt from appearing when the back button is used. It will skip over the submission process back to whatever page the user was on before that (generally submit.php).
You'll have to modify your logic in submit.php to handle this situation though. You wan't to re-populate the form fields with the user's previous entries and also be able to display any error message as to why the form didn't submit.
One way to handle this is to save all the form submissions and any error messages to the session and upon re-displaying submit.php, check to see if there is any form data in the session. If so, re-populate the form fields with the previous entries from the session and display any error messages from the session as well.
done.php
// validate form inputs here...
if (!$formIsValid) {
// save $_POST values to $_SESSION
// save any error message to $_SESSION
header('Location: /submit.php'); // redirect back to form
exit;
} else {
header('Location: /success.php'); // redirect to success page
exit;
}
Upvotes: 1