[Fixed] 4 Ways to fix Confirm Form Resubmission Error

What is Confirm Form Resubmission Error?





Confirm Form Resubmission Error is not a straightforward error instead should be taken as a warning or a message. This appears quite often in chrome browser when you try to refresh a page which is containing a form.

Confirm Form Resubmission

These forms may be

  • Credit card forms for completing transactions
  • Sign up forms and login forms
  • Contact forms which we use in contact pages
  • Search forms for searching a database
  • Or anything that has to do with add, edit or delete entries or files on a database

Why Confirm Form Resubmission appears?

It is mainly because of the reason that chrome browser doesn’t cache the forms which are created using the POST. So whenever we try to refresh the Page we see this error. As I said earlier this is not an error but a message because what this says is that ‘if we refresh the page again then we might be completing the action whether it is completing a transaction, submitting the signup form, etc.’

It might also as appear as ERR_CACHE_MISS



Sometimes it can also be very serious because when you get this during a transaction and you proceed with a ‘yes’ then there are some chances that the amount is deducted two times. So, Confirm Form Resubmission can sometimes be very easy to be left off but sometimes it may be very serious.

But, whatever the case it is always annoying. So here are some methods to solve or fix PHP Error: Confirm Form Resubmission.

Before that harrymc from Superuser says that,

Confirm Form Resubmission is a ‘feature’ included in Google Chrome to prevent users from doing the POST actions twice as said above. But this was fixed long ago in some versions of Chrome by using the parameter -disable-prompt-on-repost on the Chrome invocation but it later deemed to be non-functional.

He also notes that there is a problem with the code behind the Backward and Forward buttons on chrome. But over the updates, it has now become impossible to fix by Chrome itself. As someone has to write the function of Backward and Forward buttons from scratch.


Without being said, these fixes listed below only works if you have the ability to edit the pages containing the POST operations.

METHOD 1: Post/Redirect/Get

According to Superuser harrymc, there are two probable solutions to fix this

  • By using GET instead of POST
  • By using Post/Redirect/Get method with the 303 Redirect for redirecting the Signup page to ‘Success Message Page’ after the entry completes

If the second method is used then, when you are refreshing the page it is actually refreshing the ‘Success Message Page’ but not the ‘Transaction Page’ so you will not be charged twice.

This method is published by harrymc on Superuser

Explanation

When to use POST

POST can be used when you don’t want people to submit the data more than once, and especially when the action is involving the exchange of Sensitive information.

Such as

  • Credit Card numbers and CVV’s During a transaction
  • Login forms involving Passwords
  • Contact forms, just because you don’t want to spam the message by refreshing

When to use GET

GET can be used for everything else other than POST. GET can be used for things which don’t require the exchange of Sensitive information.

  • Unsubscribe forms using OTP’s which are meant to be used only once and then destroyed
  • Search forms in a Search Engine or a Website
  • Survey forms

How to Fix Confirm Form Resubmission by using Post/Redirect/Get

Here’s a quick example for applying this method, thanks to Mike from Stack Overflow for this example.

if(!empty($_POST['username'] && !empty($_POST['password'])) {
    $user = new User;
    $user->login($_POST['username'], $_POST['password']);

    if ($user->isLoggedIn()) {
        header("Location: /admin/welcome.php");
        exit;
    }
    else {
        header("Location: /login.php?invalid_login");
    }
}

he also mentioned that we can add,

if (isset($_GET['invalid_login'])) {
    echo "Your username and password combination is invalid";
}

to display an error message if the Username and Password combination didn’t match and don’t want to redirect them to the Login page again as it does in the first case.

This is published by Mike on Stack Overflow

Example

In this Instead of sending the user back to transaction page, we are using a 301 Redirect to send them to Results.php page where it contains a ‘Success Message’.

confirm form resubmission PHP

Here’s the Results.php Page.

confirm form resubmission Results PHP

This method is published by Dave on YouTube


METHOD 2: ‘no-store’




You can fix Confirm Form Resubmission Error if you are using a form with this in Header.

header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');

The actual problem might be in the Header.

  • To fix this try deleting the part('no-store') from the header
  • Refresh the page with the form
  • Reenter the form and refresh to check if this works

Hurray, you are done.

This method is published by Ambar on YouTube


METHOD 3: -disable-prompt-on-repost

By adding -disable-prompt-on-repost your chrome’s directory might help you solve the Confirm Form Resubmission Error.

  • Create a Google Chrome Shortcut on an easily accessible folder like a desktop or a downloads folder
  • Right-click on the Chrome Shortcut and click properties
  • You will see a dialog in which it has a field ‘Target’

Confirm Form Resubmission Google Chrome

For me, the target is “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe” its just the directory where the Chrome is located

  • Now add -disable-prompt-on-repost to the end of the target

Like this “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”-disable-prompt-on-repost

  • Save it and open Google Chrome
  • Check if you still receive Confirm Form Resubmission error

Hurray, you are done.

This method is published by Ben on Google Groups


Method 4: Update your Chrome Browser

Try updating your Browser because although Confirm Form Resubmission error still persists there might be a chance of it being fixed in newer updates so try and update your Google Chrome.

Click here to go to Google’s Support page on How to update Google Chrome.

This method is contributed by Jasie to this site


Confirm Form Resubmission error: Still, after all these methods to Fix, This is still an Alert Message and don’t try to refresh sites during important functions such as Payments, etc.

Assistance

Howdy, I Hope your Problem is solved but, If you need any Additional assistance or help regarding this error then use the form below to reply to me with a detailed explanation of the problem.


Replies Archive

Confirm Form Resubmission Error Occurred while transferring Savings to another Bank account.

Name: Jamie M Dillman

Message: Hi I hope you can help me I was just at the very end of a transaction where I was putting my savings into an account, and I made an error of some sort I believe that I capitalized some letters that were not supposed to be in the username. I am just not very good at keyboarding in my memory is not that great I should have written everything down! If there’s anything you can do to help I would really appreciate it. Thank you.

Reply:

This is not your fault, its an error from the developer side. You can prevent it by clicking on ‘Cancel’ option and wait for the transaction completed message to arrive on your contact number. There are some chances that you might not receive it due to a problem, contact the respective bank and file a complaint explaining what happened.
For clarification If the error is capitalization of letters and that didn’t match the actual credentials then you would simply receive a ‘wrong details error’ or of that sort. I think you refreshed the page or clicked on the back button due to the unresponsiveness. Don’t worry your problem will be solved either automatically or by filing a complaint to the bank.
For Information on why this error appears visit: Why Confirm Form Resubmission appears? section on https://confirmformresubmission.org/