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

后端 未结 7 1510
天涯浪人
天涯浪人 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:42

    If you aren't already using some sort of session-management (which would let you note and track form submissions), a simple solution would be to include some sort of unique identifier in the form (as a hidden element) that is either part of the main DB transaction itself, or tracked in a separate DB table. Then, when you are submitted a form you check the unique ID to see if it has already been processed. And each time the form itself is rendered, you just have to make sure you have a unique ID.

    0 讨论(0)
提交回复
热议问题