Great example
b781rev! One thing though - on this line in the PHP:
ysql_query("UPDATE ajax SET ajax_score = '$score', ajax_level = '$level'
WHERE username = 'b781rev'");
I don't know PHP very well, but it looks vulnerable to a SQL injection hack. If you request the AJAX URL with this for the score:
0';DROP DATABASE;
then you substitute that in to the SQL command and it wipes the database. You should be very careful about SQL injection - many, many sites have been hacked by that.