<?php
	header( 'content-type: text/html; charset=utf-8' );
	
	$db_host    = "localhost";
	$db_user   = "root";
	$db_pass   = "";
	$db_name   = "test";
	
	$id_reservation = $_GET['id'];
	 
	if(isset($_POST['valide']) && $_POST['valide'] == "ok")
	{ $connexion = mysql_connect($db_host,$db_user,$db_pass); 
   	  mysql_select_db($db_name, $connexion);
	  $sql = " DELETE FROM reservation where id='$id_reservation' "; 
 	  $requete = mysql_query( $sql, $connexion ) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());  
	  header("Location: liste_reservation.php");   
	 }
	 
	if(isset($_POST['valide']) && $_POST['valide'] == "annule")
	{  
		header("Location: liste_reservation.php");   
	}			      	 

?>

<script type="text/javascript">

function fct_effacer()
{
	verif = confirm("Voulez vous vraiment supprimer cette réservation ?");
 	
 	if(verif == true)
 	  { document.getElementById('valide').value="ok";
 	  }
 	
 	if(verif == false)
 	  { document.getElementById('valide').value="stop";
 	  }	

} 

function fct_annuler()
{
 
	document.getElementById('valide').value="annule";
 
} 


</script>

		

		<form action="" method="post" id="form_supprimer_reservation" name="form_supprimer_reservation"> 
		<table align="left" cellspacing="1" cellpadding="5" border="0" bgcolor="#D5D5D5" width="400">
		<tr bgcolor="#F1F3F5">
		<td colspan="2">Supprimer la réservation</td>
		</tr>
		</tr>
		
		</td>
		</tr>
				
		<input type="hidden" name="valide" id="valide" value="">
				
						
		<tr bgcolor="#FFFFFF">
		<td align="left" valign="top">Id :</td>
		<td align="left" valign="top" colspan="1"> 
		<?php echo $id_reservation; ?>
		</td>
		</tr>
			
  
		<tr bgcolor='#F1F3F5'>
        <td colspan='2' align='center'>
		<input type='submit' name='effacer' value='Effacer' onClick="fct_effacer()" />
		<input type='submit' name='Annuler' value='Annuler' onClick="fct_annuler()" />  
		</td>
		</tr> 

		</td>
		</tr>
		
		
		</table>
		</div>
		</div>
		
		</form>


		</body>
		</html>