Skip to content

Instantly share code, notes, and snippets.

@topherPedersen
Last active September 3, 2019 23:54
Show Gist options
  • Save topherPedersen/7b5f9784cc9441c95d1a6af1700b1446 to your computer and use it in GitHub Desktop.
Save topherPedersen/7b5f9784cc9441c95d1a6af1700b1446 to your computer and use it in GitHub Desktop.
Leaderboard Script
<?php
$playerName = $_POST['playerName'];
$score = $_POST["score"];
$servername = "localhost";
$username = "shranos_admin";
$password = "letsgo";
$dbname = "shranos_db";
// Create connection
$conn = new mysqli($servername,$username,$password,$dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: ".$conn->connect_error);
}
// $sql = "INSERT INTO leaderboard_table (username_column, highscore_column) VALUES ('aNub', 0)";
$sql = "INSERT INTO leaderboard_table (username_column, highscore_column) VALUES ('" . $playerName . "', " . $score . ")";
if ($conn->query($sql)===TRUE) {
// echo "New record created successfully";
echo "your moms score added to leaderboard, thx noob";
} else {
// echo "Error: ".$sql."<br>".$conn_error;
echo "ERROR: PC LOAD LETTER";
}
$conn->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment