Yes there is - I had a similar problem a couple hours ago.
Check out the ajax tutorial here:
http://www.scirra.com/tutorials/61/ajax-example-with-construct-2/page-1
Say you wanted to request savescores.php - you would need two pass two values in - one being the username for identification purposes, and the second being their score.
The PHP would look something like:
<?php
/*
You will need to create the database, then create the "scores" table by running the SQL query below.
CREATE TABLE `scores` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 20 ) NOT NULL ,
`score` INT NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = InnoDB;
*/
$db = "your_database";//Your database name
$dbu = "yourdb_user";//Your database username
$dbp = "yourpassword";//Your database users' password
$host = "localhost";//MySQL server - usually localhost
$dblink = mysql_connect($host,$dbu,$dbp);
$seldb = mysql_select_db($db);
if(isset($_GET['name']) && isset($_GET['score'])){
//Lightly sanitize the GET's to prevent SQL injections and possible XSS attacks
$name = strip_tags(mysql_real_escape_string($_GET['name']));
$score = strip_tags(mysql_real_escape_string($_GET['score']));
$sql = mysql_query("INSERT INTO `$db`.`scores` (`id`,`name`,`score`) VALUES ('','$name','$score');");
if($sql){
//The query returned true - now do whatever you like here.
echo 'Your score was saved. Congrats!';
}else{
//The query returned false - you might want to put some sort of error reporting here. Even logging the error to a text file is fine.
echo 'There was a problem saving your score. Please try again later.';
}
}else{
echo 'Your name or score wasnt passed in the request. Make sure you add ?name=NAME_HERE&score=1337 to the tags.';
}
mysql_close($dblink);//Close off the MySQL connection to save resources.
?>
EDIT: To retrieve the scores, just run mysql_fetch_array (or object, depending on your preference) and loop through the returned results. It's up to you for how you want them displayed. I suggest doing an ORDER BY `scores`.`score` DESC LIMIT 10 query so you can do a "Top 10" leaderboard.