I've a game in which my JavaScript calls PHP scripts via POST to change values in the database. How can I prevent someone repeatedly duplicating the request and giving themselves a billion points?
Right now I pass a password through sha1()
and check if it's there on the PHP side, but this wouldn't stop someone repeating the request.
I can't use timestamps because time will lapse between call (JS POST request) and run of the PHP script.
Edit:
- My PHP script doesn't increment the database values (points=points+10), it takes the values passed to it and updates the field (points=300)
- I update several tables on each interaction (well each interaction which result in points going up) in the game. One of these keeps track of every vote. This table only allows a user to vote on any image once. If I were to do this update first, if the user has tried to repeat this request, the result would return an error and I could kill the PHP script.