My application calls external PHP files to retrieve and submit information to an SQL database. Each request made is visible in the developer panel of what I assume to be any browser, and can easily be re-executed manually. It is my understanding that trying to detect the "source" of the request is not the right way to go about restricting manual invocation of scripts.
My main reason for wanting to prevent re-execution of these scripts is that they could either lead to the user giving themselves more than they've earned (UPDATE user_scores SET score = score + x
) or returning themselves to a previous state as many times as they want (UPDATE user_scores SET score = x
).
What is a tried and true method of ensuring that a query within a script that is only intended to execute once is executed the first time and never again?