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/ajouterClient.php
2019-02-11 10:24:07 +01:00

27 lines
No EOL
823 B
PHP

<?php
require_once "includes/bdd.php";
// Requête SQL ajout client
$ajouterClient = $bdd->prepare("INSERT INTO biblio_client VALUES (DEFAULT, :nom, :prenom, :sexe, :adresse, :cp, :ville, :tel, :mail)");
// Tableau informations client
$infosClient = [];
// Stockage des infos dans tableau
foreach($_POST as $key => $value){
$infosClient[$key] = $value;
}
// Exécution de la requête
$ajouterClient->execute($infosClient);
// Récupération du nouveau client
$nouveauClient = $bdd->prepare("SELECT code FROM biblio_client WHERE code = (SELECT MAX(code) FROM biblio_client)");
$nouveauClient->execute();
$nouveauClient = $nouveauClient->fetch();
?>
<script type="text/javascript">
// Redirection vers le nouveau client
window.location.href = 'client.php?code=<?= $nouveauClient['code'] ?>';
</script>