I've been trying to make a facebook game for some weeks now and I am stuck.. it probably will be a easy question to answer but it is my first time working with mysql and I didn't find something to help me in the internet.
What I want to make is a flash game where people upload their personal data like email, name, surname in the background after confirmation has been granted and been given a score where after achieving higher score the field updates if the existing value is lower.
Right about now I've managed to create this code
$dbhost = 'bla bla';
$dbuser = 'bla bla';
$dbpass = 'bla bla';
$data = 'bla bla';
$db = mysql_connect($dbhost, $dbuser, $dbpass);
if (mysql_errno() > 0) {
if (mysql_errno() == 1203) {
die("DB error");
} else {
die("DB error");
}
}
if ($_REQUEST['action'] == "add") {
mysql_select_db($data, $db);
$insert = "INSERT INTO FB (UID, first_name, last_name, email, link)
VALUES (
'".$_REQUEST['uid']."',
'".$_REQUEST['first_name']."',
'".$_REQUEST['last_name']."',
'".$_REQUEST['email']."',
'".$_REQUEST['link']."'
)";
$res = mysql_query($insert, $db) or die ("Save Error");
mysql_close($db);
echo "Added to DB!";
}
It works just fine but it has a problem.. if i submit my field again another duplicated row appears in the table with the same information.
I want the user to submit only once.. therefor having a unique row and update only his score if he manages to get a higher score.
Any help would be appreciated :)