I have a link
<a href="new link">click me</a>
when a user click the link "click me", the new link page will be redirected and do something at the server side. The problem, if a user click the back button on the browser, it will go back to the old link. If the user click the link "click me", the new link page will be opened and processing at the server side will do again. How to prevent this situation? That is even a user go back to the old page, the new link cannot be clicked anymore
Generate a unique id on the link, like therequest.do?id=1234
, and log 1234
to a database so that the request cannot be run again.
mypage.do
, server generates id 1234
and logs to database as unprocessed.therequest.do?id=1234
1234
as processed.1234
is already processed, so generates an error message on the screen: request has already been processed
.