NetTalk Central

Author Topic: Confirm Form Resubmission -Use POST/Redirect/GET??  (Read 8364 times)

JohanR

  • Sr. Member
  • ****
  • Posts: 386
    • View Profile
    • Email
Confirm Form Resubmission -Use POST/Redirect/GET??
« on: July 18, 2023, 12:10:34 AM »
Hi,

As I am testing, I get this a lot, and I know to avoid the back button, but I still do it.
So my clients/users are going to do it also.

Is there a way to minimise/eliminate this from happening?
Perhaps the way I code and the method of moving from window to window?


As I've come to notice it I have made a point of using the back/forward button on sites I use on a daily basis.
And it does happen, but then some hardly ever.
So hoping there is a way of managing it somehow?


thanks

Johan



« Last Edit: February 28, 2025, 07:26:41 AM by JohanR »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11297
    • View Profile
Re: Confirm Form Resubmission - minimize?
« Reply #1 on: July 18, 2023, 09:12:19 PM »
Hi Johan,

I'm not sure I understand from the title what your question is?
If your last action was a POST and you press the back button in the browser, then the browser asks you if you want to re-submit the post. You can answer yes or no as you desire. (It won't make any difference to the server).

Since this is a browse message, caused by using a part of the browser UI, I'm not sure what you want me to do about it?

Cheers
Bruce


Jane

  • Sr. Member
  • ****
  • Posts: 387
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Confirm Form Resubmission - minimize?
« Reply #2 on: July 19, 2023, 06:47:59 PM »
Google search for

Code: [Select]
chrome what triggers form resubmission message
You'll see a number of possible workarounds, none of which are elegant.

Jane

JohanR

  • Sr. Member
  • ****
  • Posts: 386
    • View Profile
    • Email
Re: Confirm Form Resubmission - minimize?
« Reply #3 on: July 19, 2023, 10:39:13 PM »
Hi Jane

thanks,
I do realise this is a browser UI thing, however the users will be external and I wont be able to dictate settings to them.

I was just looking for some advice/tips on anything that my code could influence to minimize the Form Resubmission.
Or if there are ways of doing something in NTWS that could be triggering the Form Resubmission, but there might be an alternative way of doing it.

Still learning on how it all fits together.
Some days with NTWS I "get it" and other days I am at the bottom of the steep learning curve. :)


Looks as if Posts and Gets play a big part,
This was interesting.
https://www.w3schools.com/tags/ref_httpmethods.asp
But I have also had situations where I only see GETS in the log, and I have the message.

I do notice that as I use other websites, some have it more than others,
so really just trying to eliminate any occurrences that my coding might trigger.

Will spend some time on this later in the project

thanks

Johan

JohanR

  • Sr. Member
  • ****
  • Posts: 386
    • View Profile
    • Email
Re: Confirm Form Resubmission - Use POST/Redirect/GET?
« Reply #4 on: February 28, 2025, 02:54:20 AM »
Hi,

Looked at this topic again to see if I can improve anything to minimise "Form Re-Submissions"
and found this

Is this something that I can implement to see if this will help and how to do that with NTWS?
If it's even possible, and will clicking the back button twice not cause the same problem?


The POST/Redirect/GET Pattern
One common way to avoid the resubmission issue is using a pattern called POST/Redirect/GET. Here's how it works:

Step 1: User submits a form using the POST method.
Step 2: Instead of simply showing the result of the form submission (e.g., a confirmation page), the server redirects the user to a new page (using a 302 redirect).
Step 3: The browser then makes a GET request to the new page, showing the result of the form submission, but this time no form data is being sent.
This way, if the user refreshes the page, it won?t trigger the form resubmission because the browser is just displaying the page after a GET request, not trying to resubmit the form.

Why Use POST/Redirect/GET?
The POST/Redirect/GET pattern is used to:

Avoid Duplicate Submissions: If the user refreshes or goes back to the page, they won?t accidentally submit the same form data again.
Improve User Experience: Users are not confused by a resubmission warning when refreshing or navigating back.
Prevent Unintended Actions: This ensures that critical actions (like payments or orders) are not unintentionally repeated due to a page refresh or navigation.


thanks

Johan

« Last Edit: February 28, 2025, 07:26:10 AM by JohanR »

rjolda

  • Sr. Member
  • ****
  • Posts: 354
    • View Profile
    • Email
Re: Confirm Form Resubmission -Use POST/Redirect/GET??
« Reply #5 on: February 28, 2025, 02:01:07 PM »
Johan,
Did you implement this yet in Net Talk?  I would be interested in seeing how you did this.
Ron

JohanR

  • Sr. Member
  • ****
  • Posts: 386
    • View Profile
    • Email
Re: Confirm Form Resubmission -Use POST/Redirect/GET??
« Reply #6 on: March 02, 2025, 12:34:18 AM »
Hi Ron,

No I have not,
but would like to at some point see if anything can be done, from my design, flow or coding to lessen the Form Re-Submission message.


regards

Johan