This repository has been archived on 2022-10-26. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
biblio/ajouterGenre.php
2019-02-11 10:24:07 +01:00

27 lines
No EOL
725 B
PHP

<?php
require_once "includes/bdd.php";
// Requête SQL ajout genre
$ajouterGenre = $bdd->prepare("INSERT INTO biblio_genre (nom) VALUES (:nom)");
// Tableau informations genre
$infosGenre = [];
// Stockage des infos dans tableau
foreach($_POST as $key => $value){
$infosGenre[$key] = $value;
}
// Exécution de la requête
$ajouterGenre->execute($infosGenre);
// Récupération du nouveau genre
$nouveauGenre = $bdd->prepare("SELECT id FROM biblio_genre WHERE id = (SELECT MAX(id) FROM biblio_genre)");
$nouveauGenre->execute();
$nouveauGenre = $nouveauGenre->fetch();
?>
<script type="text/javascript">
// Redirection vers le nouveau genre
window.location.href = 'genre.php?id=<?= $nouveauGenre['id'] ?>';
</script>