site-accueil-insa/admin/mots_croises.php
thaaoblues 295e26d64e test
2023-07-02 19:40:26 +02:00

83 lines
No EOL
2.1 KiB
PHP

<?php
include "script.php";
include "../script/db_init.php";
if($user['perm'] < 3) {
header('Location: deco.php');
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Admin / Mots croisés</title>
</head>
<body>
<?php
if(isset($_POST["AJ_MOT"])){
echo "set";
$mot = htmlspecialchars($_POST["mot"]);
echo "htsp";
$req = $db->prepare("INSERT INTO mots_croise(name,trouve) VALUES(?,?)");
echo "prep";
$req->execute(array($mot,FALSE));
echo "exec";
}
if(isset($_POST["SUPP_MOT"])){
$req = $db->prepare("DELETE FROM mots_croise WHERE id=?");
$req->execute(array($_POST["id_mot"]));
}
?>
<main>
<form method="POST">
<input type="text" name="mot" id="mot_input" placeholder="mot à deviner" class="input_inline">
<input type="text" name="AJ_MOT" value="AJ_MOT" hidden>
<input type="submit" value="ajouter ce mot" class="submit_inline">
</form>
<h4>/!\Ajoutez les mots dans l'ordre de la grille/!\<h4>
<?php
$req = $db->query('SELECT * FROM mots_croise');
?>
<table class="acces">
<tr>
<th width="10%">ID (db)</th>
<th width="60%">Mot</th>
<th width="30%">Action</th>
</tr>
<?php
while($mot = $req->fetch()) {
?>
<tr>
<td><?= $mot['id'] ?></td>
<td><?= $mot['name'] ?></td>
<td>
<form method="POST">
<input type="text" name="SUPP_MOT" value="SUPP_MOT" hidden>
<input type="number" value="<?=$mot['id']?>" name="id_mot" hidden>
<input type="submit" value="supprimer" class="submit_inline">
</form>
</td>
</tr>
<?php } ?>
</table>
</main>
</body>