Are there any best practices for preventing users from executing the script multiple times?

To prevent users from executing a script multiple times, you can implement a simple check to see if the script has already been executed by setting a flag in a session variable. If the flag is set, the script should exit early to prevent duplicate execution.

session_start();

if(isset($_SESSION['script_executed'])) {
    // Script has already been executed, exit early
    exit;
}

// Your script code here

// Set flag to indicate script has been executed
$_SESSION['script_executed'] = true;