Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F5 (refresh) act as submit

I have a hidden parameter called 'act' that should pass one of the values 'load', 'save' on pressing the submit button.

The problem is when pressing on the F5 (refresh) button after pressing the submit button because the url already contain '&act=save' so prssing on F5 actually pass (to cgi) the 'save' value again (and it perform the save action again even I didn't press on the submit button.

The queston is how can I prevent sending the '&act=save' on pressing the reffresh button?

Thanks


Thanks you all but the submit button is a 'save' button - means I wish to leave the user the abbility to perfrom addiitonal save so don't wany to leave the page. From this reason, I don't think that the session may help to distinguish between the second save or the first refresh.

like image 489
Mike Avatar asked Feb 23 '23 18:02

Mike


1 Answers

The core problem here is that you are using GET when you should be using POST. The HTTP specification says:

In particular, the convention has been established that the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval.

If you were using POST then the browser would, at least, warn you about resubmitting a form.

To avoid even that, use the POST-Redirect-GET pattern.

like image 62
Quentin Avatar answered Mar 05 '23 00:03

Quentin