<?php
session_start();
$conn = new mysqli("localhost","root","","breakout_db");

if(!isset($_SESSION['user']) || !isset($_GET['score']) || !isset($_GET['diff'])) {
    exit;
}

$u = $_SESSION['user'];
$s = intval($_GET['score']);
$diff = $_GET['diff'];

$column = "";
if($diff === 'easy') {
    $column = "highscore_easy";
} elseif ($diff === 'medium') {
    $column = "highscore_medium";
} elseif ($diff === 'hard') {
    $column = "highscore_hard";
}

if($column != "") {
    $conn->query("UPDATE users SET $column = GREATEST($column, $s) WHERE username='$u'");
}
?>