This commit is contained in:
2019-11-01 02:39:44 +01:00
parent bfe422bbdd
commit 5de5f03b3c
10 changed files with 304 additions and 129 deletions

14
publish.php Normal file
View File

@ -0,0 +1,14 @@
<?php
include "db_connect.php";
if (isset($_POST['player']) && isset($_POST['score'])) {
try {
$db = new PDO("mysql:host=$DB_HOST;dbname=$DB_NAME;charset=utf8", $DB_USER, $DB_PASSWORD);
} catch (Exception $e) {
die('Erreur : ' . $e->getMessage());
}
$query = $db->prepare('INSERT INTO `leaderboard` (`player`, `score`) VALUES (:player, :score);');
$query->execute(array("player" => strip_tags($_POST['player']), "score" => (int) $_POST['score']));
} else {
header($_SERVER["SERVER_PROTOCOL"] . " 405 Method Not Allowed", true, 405);
}
?>