From 31ede4dc57d1cf16c6139d0ecdf29d506d6753b5 Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Mon, 19 Sep 2022 11:06:53 +0200 Subject: [PATCH] ajout cloture database\najout votes dans database --- gestionsite/saisieVotation.php | 1 + gestionsite/saisieVotes.php | 25 +++++++++++++++++++------ include/fonctions.inc.php | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/gestionsite/saisieVotation.php b/gestionsite/saisieVotation.php index 6e412c7..1ed7ba1 100644 --- a/gestionsite/saisieVotation.php +++ b/gestionsite/saisieVotation.php @@ -27,6 +27,7 @@ if ($titre !== null and $libelle!== null and $dateDebut!== null and $dateFin !== $db = new db(); $query = "INSERT INTO liste_votations ('titre', 'libelle', 'status', 'dateDebut', 'dateFin') VALUES('" . $titre . "', '" . $libelle . "', '0', '" . $dateDebut . "', '" . $dateFin . "')"; // clotûre $db->query($query); + $db->close; }else { votationForm($path, $titre, $libelle, $dateDebut, $dateFin); diff --git a/gestionsite/saisieVotes.php b/gestionsite/saisieVotes.php index 7aeb845..72ff932 100644 --- a/gestionsite/saisieVotes.php +++ b/gestionsite/saisieVotes.php @@ -5,16 +5,17 @@ require_once 'db.class.php'; require_once 'entete.php'; require_once 'fonctions.inc.php'; -$idVotation = getpost("id"); -$path = $_SERVER["PHP_SELF"]; print('

') . EOL; print('
-

Nouveau vote

-

'); +

Nouveau vote

'); + +$path = $_SERVER["PHP_SELF"]; +$idVotation = getpost("id"); + if (empty($idVotation)) { if (array_key_exists("idVotation", $GLOBALS)) @@ -25,8 +26,20 @@ if (empty($idVotation)) choixVotation($path); } } -print(""); -votesForm($path); + +$method = getpost("method"); +$libelle = getpost("libelle"); +if (empty($method) or empty($libelle)) +{ + votesForm($path); +}else +{ + $db = new db(); + $query = "INSERT INTO liste_votes ('libelle', 'method', 'id_votation') VALUES ('" . $libelle . "', '" . $method . "', '" . $idVotation . "')"; + print($query); + //$db->query($query); + $db->close; +} print('
diff --git a/include/fonctions.inc.php b/include/fonctions.inc.php index 6fed846..de7ec8b 100644 --- a/include/fonctions.inc.php +++ b/include/fonctions.inc.php @@ -115,7 +115,7 @@ function votesForm($path, $libelle = "", $method = 0)