3
This commit is contained in:
parent
98aa2e3c0c
commit
d95336537a
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
session_start();
|
||||||
require_once 'auth_check.php'; // Protect this page
|
require_once 'auth_check.php'; // Protect this page
|
||||||
require_once 'db/config.php';
|
require_once 'db/config.php';
|
||||||
|
|
||||||
@ -109,4 +110,4 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
session_start();
|
||||||
require_once 'auth_check.php'; // Protect this page
|
require_once 'auth_check.php'; // Protect this page
|
||||||
require_once 'db/config.php';
|
require_once 'db/config.php';
|
||||||
|
|
||||||
@ -12,9 +13,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
if (empty($tournament_name)) {
|
if (empty($tournament_name)) {
|
||||||
$error_message = 'Please fill in the tournament name.';
|
$error_message = 'Please fill in the tournament name.';
|
||||||
} else {
|
} else {
|
||||||
// In a real scenario, you would insert this into a 'tournaments' table
|
try {
|
||||||
// For now, we just show a success message.
|
$pdo = db();
|
||||||
$success_message = 'Tournament "' . htmlspecialchars($tournament_name) . '" would have been added (functionality pending).';
|
$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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
12
db/setup.php
12
db/setup.php
@ -31,6 +31,16 @@ try {
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
) 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
|
// Check if superadmin exists
|
||||||
$stmt = $pdo->prepare("SELECT id FROM users WHERE username = 'superadmin'");
|
$stmt = $pdo->prepare("SELECT id FROM users WHERE username = 'superadmin'");
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
@ -56,4 +66,4 @@ try {
|
|||||||
|
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
die("Database setup failed: " . $e->getMessage());
|
die("Database setup failed: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user