Why You Keep Seeing “Confirm Form Resubmission” — And How to Fix It

Ever filled out a form online and then hit back or refresh — only to see a weird “Confirm form resubmission” message?

It’s annoying. And more importantly, it’s not just how the internet works — it’s actually a result of how the form was built.

If you're building apps, handling payments, or collecting user data, this is one of those small UX bugs that can make your product feel clunky. Let me break down why it happens — and how to fix it.


The Real Problem

That “resubmission” message usually shows up when a form uses the wrong HTTP method — typically POST — and the page doesn't redirect afterwards.

You’ll want to understand when to use GET vs POST. Here’s the cheat sheet:


When to Use POST (Most of the Time)

Use POST when the action:

  • Changes data (like creating, updating, or deleting records)

  • Handles sensitive info (like login credentials or payments)

  • Involves file uploads

  • Or includes a ton of form fields (i.e. super long URLs)

Examples:

  • Login form

  • Contact form

  • Checkout form

  • Database updates

  • File uploads

The key thing with POST is that you don’t want the user to accidentally repeat the action by refreshing the page. Especially if that action charges a credit card.


When to Use GET

Use GET when:

  • It’s okay to repeat the action

  • You’re just displaying info

  • You want a shareable URL

  • There's no sensitive data or file uploads

Examples:

  • Search bars

  • Navigation forms

  • Unsubscribe links

Imagine if Google search used POST — you wouldn’t be able to share links or hit refresh without resubmitting the search.


How to Fix the Resubmission Bug

If you're using POST (as you should in many cases), the fix is simple:

👉 Use the Post/Redirect/Get (PRG) pattern.

Here’s how it works:

  1. User submits a form using POST.

  2. The server processes it.

  3. Instead of returning a page directly, you redirect the browser to a new URL using GET.

That way, refreshing the page just reloads the final screen — not the original form submission.


Here’s a Quick PHP 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");
        exit;
    }
}

And to show an error on the login page:

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

Notice that even when login fails, the user gets redirected — which avoids the resubmission issue entirely.

0 comentarios

Dejar un comentario

Ten en cuenta que los comentarios deben aprobarse antes de que se publiquen.