Why not using some php-files for doing the important calculations on the serverside?

For example the file foundCoin.php is called if the player found a coin: The file asks the database if there is really a coin on the players field, add the coin to the players coins and echo 0 for error or 1 for success simply?

Any suggestions about the speed of this solution?