site-accueil-insa/admin/mots_croises.php

81 lines
2.1 KiB
PHP
Raw Normal View History

2023-06-22 17:30:50 +02:00
<?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"])){
$mot = htmlspecialchars($_POST["mot"]);
$req = $db->prepare("INSERT INTO mots_croise(name,trouve) VALUES(?,?)");
$req->execute(array($mot,FALSE));
2023-07-02 19:37:53 +02:00
}else{
2023-07-02 19:38:25 +02:00
echo $_POST["AJ_MOT"];
2023-06-22 17:30:50 +02:00
}
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" value="" 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>