How can I prevent database being written to again when the browser does a reload/back?

后端 未结 7 1514
天涯浪人
天涯浪人 2021-01-06 01:06

I\'m putting together a small web app that writes to a database (Perl CGI & MySQL). The CGI script takes some info from a form and writes it to a database. I notice, h

7条回答
  •  执念已碎
    2021-01-06 01:40

    Do a POST every time you alter data, but never return an HTML response from a post... instead return a redirect to a GET that retrieves the updated data as a confirmation page. That way, there is no worry about them refreshing the page. If they refresh, all that will happen is another retrieve, never a data-altering action.

提交回复
热议问题