Refresh is a nice feature on browsers to use when you've gone too far, or have updated the style in your page.
However, it can bite you on occasion.
What happens when you refresh a screen is that the browser resubmits the previous screen, and shows the result. This can cause a problem when the world has moved on. Such as when you've just clicked 'Add' to enter a new row of data to your database. On such occasions, the add request will be repeated, and a new and duplicate row will be added.
The first approach to fixing this problem might be to store the newly added row id in the form. If 'Add' has just occurred, and this id exists, then ignore the call.
...doesn't work. Remember, the refresh call is sending a cached set of post data. This will include the old values of any state flags you set to try and avoid the problem. What was right last time, therefore , will be right this time and...
The only solution to this that I have found is to store your state variables as a server side 'session' variable. Now, when your cached post data is received, it is checked against the current session state, which will have stored the fact that you just did an add with this data.
As someone once said: 'Life wasn't meant to be easy'