44 lines
1.5 KiB
PHP
44 lines
1.5 KiB
PHP
<?php
|
|
require_once 'database.php';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
foreach ($_POST as $name => $value) {
|
|
$stmt = $db->prepare('UPDATE configuration SET value = ? WHERE name = ?');
|
|
$stmt->execute([$value, $name]);
|
|
}
|
|
header('Location: config.php');
|
|
exit;
|
|
}
|
|
|
|
$stmt = $db->query('SELECT * FROM configuration');
|
|
$config = $stmt->fetchAll(PDO::FETCH_KEY_PAIR);
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Configuration - Last Days of Rome</title>
|
|
<link rel="stylesheet" href="style.css">
|
|
<link rel="stylesheet" href="config.css">
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>Configuration</h1>
|
|
<form method="POST">
|
|
<?php foreach ($config as $name => $value): ?>
|
|
<div class="form-group">
|
|
<label for="<?= $name ?>"><?= ucwords(str_replace('_', ' ', $name)) ?></label>
|
|
<?php if (strlen($value) > 80): ?>
|
|
<textarea id="<?= $name ?>" name="<?= $name ?>"><?= htmlspecialchars($value) ?></textarea>
|
|
<?php else: ?>
|
|
<input type="text" id="<?= $name ?>" name="<?= $name ?>" value="<?= htmlspecialchars($value) ?>">
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<button type="submit">Save Configuration</button>
|
|
</form>
|
|
<a href="index.php">Back to Game</a>
|
|
</div>
|
|
</body>
|
|
</html>
|