1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| <?php
require 'includes/connect_bdd.php'; // connection à la base de données
if(session_status() == PHP_SESSION_NONE){
session_start();
}
foreach($_POST as $key => $val) echo '$_POST["'.$key.'"]='.$val.'<br />';
// Ajout d'une prestation
if (isset($_POST['nom_prestation']) AND isset($_POST['codage_prestation']) AND isset($_POST['montant_sans_hn']) AND isset($_POST['montant_hn']) AND !isset($_POST['id_prestation'])) {
$nom_prestation = htmlspecialchars($_POST['nom_prestation']);
$codage_prestation = htmlspecialchars($_POST['codage_prestation']);
$montant_sans_hn = htmlspecialchars($_POST['montant_sans_hn']);
$montant_hn = htmlspecialchars($_POST['montant_hn']);
$req = $bdd->prepare('INSERT INTO prestations(nom, codage, montant_hn, montant_sans_hn) VALUES(:nom_prestation, :codage_prestation, :montant_hn, :montant_sans_hn)');
$req->execute(array(
'nom' => $nom_prestation,
'codage' => $codage_prestation,
'montant_hn' => $montant_hn,
'montant_sans_hn' => $montant_sans_hn
));
$req->closeCursor(); // termine le traitement de la requête
$_SESSION['flash']['success'] = 'Prestation ajoutés à la base de données';
header('Location: parametres.php');
exit();
} |
Partager