site-accueil-insa/admin/mots_croises.php

80 lines
2.1 KiB
PHP
Raw Permalink 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(?,?)");
2023-07-02 19:42:29 +02:00
$req->execute(array($mot,0));
2023-07-02 19:40:26 +02:00
echo "exec";
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">
2023-07-02 19:39:12 +02:00
<input type="text" name="mot" id="mot_input" placeholder="mot à deviner" class="input_inline">
2023-06-22 17:30:50 +02:00
<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>