Dash-Da-Dash-DX-2023-Fan-Pa.../input_ddd_scoreboard.php

43 lines
1.1 KiB
PHP
Executable File

<?php
echo file_get_contents("ddd_source.html");
// Load the configuration file
$configFilePath = 'config.cfg';
$config = parse_ini_file($configFilePath, true);
// Include the MySQL connection script from the config file
include($config['mysql']['mysqlconnect_path']);
$b64 = $_POST["gamePass"];
$decode = base64_decode($b64, true);
$dataArr = explode("|", $decode);
$name = $dataArr[0];
$score = $dataArr[1];
$mode = $dataArr[2];
// Retrieve the boss names dynamically
$bosses = array_slice($dataArr, 3);
// Join the boss names into a single string separated by commas
$bossNames = implode(", ", $bosses);
echo $name . "<br>" . $score . "<br>" . $mode . "<br>";
echo "Bosses: " . $bossNames . "<br>";
// Prepare an SQL statement
$stmt = $conn->prepare("INSERT INTO ddd_db.scores (Name, Score, Mode, Bosses) VALUES (?, ?, ?, ?)");
$stmt->bind_param("siss", $name, $score, $mode, $bossNames);
// Execute the statement
if ($stmt->execute()) {
echo "New record created successfully";
} else {
echo "Error: " . $stmt->error;
}
$stmt->close();
$conn->close();
?>
<br>
<a class='ddd' href='ddd_index.php'>Back</a>