Perl and refresh button, save twice?

Hi guys,

I am writing a simple script save_me.cgi that can save the data in form.html into a txt (data.txt)file.
But when user click "refresh" button one the browser on page save_me.cgi, the data will be save again in the data.txt.

could someone help me on this issue?

a studpid way might be check the whole file and see any repeat records. but I would try to avoid this if possible.

Thanks

You could use a POST method to submit the data so the browser will popup a confirmation request to the user when refreshing that page.

You could also have the script redirect the browser to a different page when outputting the result of the POST.

And there are some HTML meta tags that could be used to solve that specific problem.. but I can't remember them.

You may use session (such as CGI::Session) to handle this. Generate a random ID as hidden form parameter in your form, and write it to the session when finished updating the records. Before each save operation, check whether the ID exists in the session. If so, the page has been refreshed; otherwise, commit it.

Form parameters can be refreshed, but session entries are created on the server so they are a reliable source to detect occurrences of page refreshes.

guys