<?php
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"];
print('<br><br>
	<!-- lalis Grid Section -->

	<section id="content">
		<div class="container">');
print('			  <div class="row">
					<div class="col-lg-12 text-center">
						<h3>Nouvelle votation</h3>
						<h4>');

$titre 		= getpost("titre");
$libelle 	= getpost("libelle");
$dateDebut 	= getpost("dateDebut");
$dateFin	= getpost("dateFin");

if ($titre !== null and $libelle!== null and $dateDebut!== null and $dateFin !== null)
{
	$db = new db();
	$query = "INSERT INTO liste_votations VALUES(0, '" . $db->protect($titre) . "', '" . $db->protect($libelle) . "', '0', '" . $db->protect($dateDebut) . "', '" . $db->protect($dateFin) . "')";    // clotûre
	$db->query($query);
	$db->close();
	// TODO retour à l'index
}else
{
	votationForm($path, $titre, $libelle, $dateDebut, $dateFin);
}

print('					</div>
					</div>
				</form>
			</div>
		</section>');
require_once("footer.html");

?>
