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

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

    I find it handy to track the number of form submissions the user has performed in their session. Then when rendering the form I create a hidden field that contains that number. If the user then resubmits the form by pressing the back button it'll submit the old # and the server can tell that the user has already submitted the form by examining what's in the session to what the form is saying.

    Just my 2 cents.

提交回复
热议问题