30 lines
611 B
PHP
30 lines
611 B
PHP
<?php
|
|
session_start();
|
|
require_once 'db.php';
|
|
|
|
if (!isset($_SESSION['username'])) {
|
|
echo "NO_SESSION";
|
|
exit;
|
|
}
|
|
|
|
if (!isset($_POST['difficulty'], $_POST['time'])) {
|
|
echo "NO_POST";
|
|
exit;
|
|
}
|
|
|
|
$username = $_SESSION['username'];
|
|
$difficulty = $_POST['difficulty'];
|
|
$time = (int) $_POST['time'];
|
|
|
|
$sql = "INSERT INTO leaderboard_sudoku
|
|
(username, difficulty, time_seconds)
|
|
VALUES (:username, :difficulty, :time)";
|
|
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->execute([
|
|
':username' => $username,
|
|
':difficulty' => $difficulty,
|
|
':time' => $time
|
|
]);
|
|
|
|
echo "SUCCESS"; |