diff --git a/gestion/saisieVotes.php b/gestion/saisieVotes.php index 531e5d9..0f4e36b 100644 --- a/gestion/saisieVotes.php +++ b/gestion/saisieVotes.php @@ -2,7 +2,6 @@ require_once '../session_init.php'; require_once 'config.inc.php'; require_once 'db.class.php'; -require_once 'entete.php'; require_once 'fonctions.inc.php'; $path = $_SERVER["PHP_SELF"]; @@ -25,19 +24,36 @@ function queryVotes($db, $idVotation) } $idVotation = getpost("id"); +$method = getpost("method"); +$libelle = getpost("libelle"); + + if (!empty($idVotation)) { - $_SESSION["idVotation"] = $idVotation; - $votationName = queryVotationName($db, $idVotation); -}elseif (array_key_exists("idVotation", $_SESSION)) -{ - if (!empty($_SESSION["idVotation"])) + if (!empty($method) and !empty($libelle)) { - $idVotation = $_SESSION["idVotation"]; + $query = "INSERT INTO liste_votes VALUES (0, '" . $libelle . "', " . $method . "," . $idVotation . ")"; + $db->query($query); + header("Location: " . $$base_url . "/" . $path , TRUE, 301); + return; + }else + { + $_SESSION["idVotation"] = $idVotation; $votationName = queryVotationName($db, $idVotation); } +}else +{ + if (array_key_exists("idVotation", $_SESSION)) + { + if (!empty($_SESSION["idVotation"])) + { + $idVotation = $_SESSION["idVotation"]; + $votationName = queryVotationName($db, $idVotation); + } + } } +require_once 'entete.php'; print('

@@ -58,7 +74,7 @@ if (!empty($votes)) echo EOLH . EOLH; } -print('

Nouveau vote pour la votation'); +print('

Nouveau vote pour la votation'); if (empty($idVotation)) { @@ -66,20 +82,16 @@ if (empty($idVotation)) }else { print(": " . $votationName . '

' . EOL); - $method = getpost("method"); - $libelle = getpost("libelle"); + if (empty($method) or empty($libelle)) { votesForm($path); }else { - $query = "INSERT INTO liste_votes VALUES (0, '" . $libelle . "', " . $method . "," . $idVotation . ")"; - print($query); - $db->query($query); + } } $db->close(); - print('