I have a game where you can submit your score to a database, but for some reason the submission keeps getting triggered twice. Every entry is doubled. I've seen similar problems posted here, and the solution had to do with the if/else check at the end, but I don't see a problem.
Is it my PHP code that's duplicating the entries or my game application?
<?php
$servername = "xxx";
$username = "xxx";
$password = "xxx";
$dbname = "xxx";
$port = "xxx";
$link = mysqli_connect($servername, $username, $password, $dbname, $port);
// Security
$playerInitials = mysqli_real_escape_string($link,$_REQUEST['initials']);
$playerEmail = mysqli_real_escape_string($link,$_REQUEST['email']);
$playerScore = mysqli_real_escape_string($link,$_REQUEST['score']);
// Convert Initials to Upper Case
$playerInitialsUC = strtoupper($playerInitials);
$sql = "INSERT INTO xmas (initials, email, score)
VALUES ('$playerInitialsUC', '$playerEmail', '$playerScore')";
if(mysqli_query($link, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: " . mysqli_error($link);
}
mysqli_close($link);
?>