Users Upgrade executes SQL


Is it possible to make it so that if someone buys an upgrade say for like a game. It is able to run a SQL file or query on a different database on a completely different server.

So say they buy GameUpgrade on the forum it runs the query for a GameUpgrade on the game server.

or is it possible to just execute a file that I put such as GameUpgrade.php which has the right SQL to upgrade the user. If possible how can I check that users cant directly go to that link without buying first.

Help would be great :)