<?php
include('include/entete.php');
include('include/entete_cfa.php');
include('config/config.inc.php');

if(isset($_GET['id']) && !empty($_GET['id'])){
	
	foreach($_POST as $cle=>$val) $$cle=$val;
	
	$query="select * from capitaines where id_cap=:id_cap and num_eta=:num_eta";
	$db = connect_base();
	$queryRequest = $db->prepare( $query );
	$queryRequest->bindParam( ':id_cap', $_GET['id'], PDO::PARAM_INT );
	$queryRequest->bindParam( ':num_eta', $_SESSION['cfa_num'], PDO::PARAM_INT );
	$queryRequest->execute();
	if($queryRequest->rowCount()==0){
		header('location:index-cfa.php');
		exit();
	}
	
	$query="delete from capitaines where id_cap=:id_cap";
	$db = connect_base();
	$queryRequest = $db->prepare( $query );
	$queryRequest->bindParam( ':id_cap', $_GET['id'], PDO::PARAM_INT );
	$queryRequest->execute();
	
	$query="delete from equipes where num_capitaine=:id_cap";
	$db = connect_base();
	$queryRequest = $db->prepare( $query );
	$queryRequest->bindParam( ':id_cap', $_GET['id'], PDO::PARAM_INT );
	$queryRequest->execute();
	
	header('location:index-cfa.php');
	exit();
}
	header('location:index-cfa.php');
	exit();

?>