site-accueil-insa/admin/enigma.php

86 lines
2.1 KiB
PHP
Raw Normal View History

2022-06-14 23:36:26 +02:00
<?php
include "script.php";
if($user['perm'] < 2) {
header('Location: deco.php');
}
2022-06-15 22:58:37 +02:00
$req = $db->query("SELECT * FROM enigma WHERE id = 1");
$r = $req -> fetchAll(PDO::FETCH_ASSOC);
if(isset($_POST['send'])) {
2022-06-16 14:38:31 +02:00
if($user['perm'] >= 2) {
if(isset($_POST['answer']) AND !empty($_POST['answer'])) {
$ans = htmlspecialchars($_POST['answer']);
$req = $db->prepare("UPDATE enigma SET answer = ? WHERE id = 1");
$req->execute(array($ans));
}
if(isset($_POST['points']) AND !empty($_POST['points'])) {
$point = (int) htmlspecialchars($_POST['points']);
$req = $db->prepare("UPDATE enigma SET point = ? WHERE id = 1");
$req->execute(array($point));
}
if(isset($_POST['team']) AND !empty($_POST['team'])) {
switch (htmlspecialchars($_POST['team'])) {
case "t":
$t_int = NULL;
break;
case "t0":
$t_int = 0;
break;
case "t1":
$t_int = 1;
break;
}
$req = $db->prepare("UPDATE enigma SET team = ? WHERE id = 1");
$req->execute(array($t_int));
2022-06-15 22:58:37 +02:00
}
2022-06-16 14:38:31 +02:00
header('Refresh:0');
2022-06-15 22:58:37 +02:00
}
}
2022-06-15 17:35:34 +02:00
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Admin / Enigma</title>
</head>
<body>
<main>
2022-06-15 22:58:37 +02:00
<form method="POST">
<input type="texte" name="answer" placeholder="answer" class="input_inline">
<input type="number" name ="points" placeholder="points" class="input_inline">
<select name="team" class="input_inline">
<option value="t">NULL</option>
<option value="t0">Pkpeach</option>
<option value="t1">Boomario</option>
</select>
<input type="submit" name="send" value="Mettre à jour" class="submit_inline">
</form>
<table class="acces">
<tr>
<th width="10%">ID (db)</td>
<th width="40%">Answer</td>
<th width="20%">Points</td>
<th width="10%">Team</td>
</tr>
<tr>
<td><?= $r[0]['id'] ?></td>
<td><?= $r[0]['answer'] ?></td>
<td><?= $r[0]['point'] ?></td>
<td><?php
switch ($r[0]['team']) {
case "0":
echo "Pkpeach";
break;
case "1":
echo "Boomario";
break;
}
?></td>
</tr>
</table>
2022-06-15 17:35:34 +02:00
</main>
</body>
</html>