I've created an online leader board for Tawg, and I thought I'd share the code.
Here is the code I use to save and insert a new row into my Mysql database with the player name and his score.
first the AppGameKit code
//create our connection
connect = CreateHTTPConnection()
//set our host site
SetHTTPHost( connect, "your.com" , 0 )
//send HTTP Post variables(name$ and Score) to the php script on the host site
result$ = SendHTTPRequest( connect,"/your.php","postname="+name$+"&postscore="+str(score) )
//close the connection
CloseHTTPConnection(connect)
Now the PHP script(your.php) on the server where we collect the Post data
<?php
// User Variables to connect to our Database
$user="**********";
$pass="***********";
//the Database to access
$db="**********";
// error message to be displayed if we cant connect to the database
$con_error="Could not connect";
// connect to our database with our assigned variables and then select the database
if(!@mysql_connect("localhost", $user, $pass) || !@mysql_select_db($db)) {
die($con_error);
}
//store our HTTP POST variables sent with the AGK SendHTTPRequest()
$name = $_POST['postname'];
$score = $_POST['postscore'];
//Insert a new row into our database table called score (name,score) with our POST values('postname','postscore')
$query="INSERT INTO score( name, score) VALUES( '$name',$score)";
if ($result=mysql_query($query)) {
echo "Query Succeeded";
} else {
echo "Query Failed" ;
echo mysql_error();
}
mysql_close();
?>
Auger