ajoutReservation.php 1.8 KB
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8"/>
		<title>Page principale</title>
		<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"
		      rel="stylesheet"
		      integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x"
		      crossorigin="anonymous">
		<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js"
			integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//E1J19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4"
			crossorigin="anonymous">
		</script>
	</head>
	<body>
		<?php 
			session_start();
			if(isset($_SESSION['identifiant'])){
				$login = $_SESSION['identifiant'];
				echo "Vous etes : $login <br>";
			}
			include("connexion.php");
			if(isset($_POST['txtDate']) && isset($_POST['banc']) && isset($_POST['heure'])){
				$date = $_POST['txtDate'];
				$banc = $_POST['banc'];
				$heure = $_POST['heure'];
				echo "date = ".$date." // banc = ".$banc." // heure = ".$heure."<br>" ;
				$explosion = explode('-',$date);
				$annee = $explosion[0];
				$mois = $explosion[1];
				$jour = $explosion[2];
				$date = $jour."/".$mois."/".$annee;
				echo "New date = ".$date."<br>";
				$heurefin = (int)$heure + 1;
				if($heurefin==24){
					$heurefin = 0;
				}
				if(strlen($heurefin)==1){
					$heurefin = "0".$heurefin;
				}
				if(strlen($heure)==1){
					$heure = "0".$heure;
				}
				$heure = $heure.":00";
				$heurefin = $heurefin.":00";
				echo "Heure = ".$heure."<br>";
				echo "Heure de fin = ".$heurefin."<br>";
				
				$requete = "INSERT INTO reservation VALUES($banc,'$date','$login','$heure','$heurefin')";
				$exec_requete = mysqli_query($db,$requete);
				echo "<meta http-equiv=\"refresh\" content=\"0;url=mesReservations.php\">";
			}else{
				echo "Pas marché";
			}
			mysqli_close($db);
		?>
	</body>
</html>