This commit is contained in:
Flatlogic Bot 2025-10-20 23:38:41 +00:00
parent 98aa2e3c0c
commit d95336537a
3 changed files with 24 additions and 5 deletions

View File

@ -1,4 +1,5 @@
<?php
session_start();
require_once 'auth_check.php'; // Protect this page
require_once 'db/config.php';

View File

@ -1,4 +1,5 @@
<?php
session_start();
require_once 'auth_check.php'; // Protect this page
require_once 'db/config.php';
@ -12,9 +13,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (empty($tournament_name)) {
$error_message = 'Please fill in the tournament name.';
} else {
// In a real scenario, you would insert this into a 'tournaments' table
// For now, we just show a success message.
$success_message = 'Tournament "' . htmlspecialchars($tournament_name) . '" would have been added (functionality pending).';
try {
$pdo = db();
$stmt = $pdo->prepare(
'INSERT INTO tournaments (name, description) VALUES (?, ?)'
);
$stmt->execute([$tournament_name, $description]);
$success_message = 'Tournament \''. htmlspecialchars($tournament_name) .'\' has been added successfully!';
} catch (PDOException $e) {
$error_message = 'Database error: ' . $e->getMessage();
}
}
}
?>

View File

@ -31,6 +31,16 @@ try {
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
");
// Create tournaments table
$pdo->exec("
CREATE TABLE IF NOT EXISTS `tournaments` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(255) NOT NULL,
`description` TEXT,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
");
// Check if superadmin exists
$stmt = $pdo->prepare("SELECT id FROM users WHERE username = 'superadmin'");
$stmt->execute();