<?php
session_start();
include('../connexion.php');
if (!isset($_SESSION['celest']))
{
	header ('Location: index.php');
}
if (isset($_GET['W9mvyDvFWE5']))
{
	$chaiz=addslashes($_GET['W9mvyDvFWE5']);
	$id=addslashes($_GET['QYtgoGbhhd']);
	$active=$chaiz;

	$sql= 'SELECT * FROM information WHERE id_information="'.$id.'"';
	$reponse=$bdd->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
	$data=$reponse->fetch();

	if($data[0]==NULL)
	{
		header('Location: administration.php');
	}
	?>
	<?php include('tete.php'); ?>
    <link rel="stylesheet" type="text/css" href="style/style_admin.css" />
</head>
<body>
    <div id="wrapper">
    	<?php include('menu_admin.php'); ?>
        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-3 col-md-3 col-sm-3"></div>
                <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12" id="administration">
                    <div id="titro_admin">Suppression <?php echo $chaiz ?></div>
                    <div align="center">
						<?php
						if (isset($_POST['valider']))
						{
							$sql = 'SELECT *
							FROM image
							WHERE id_information='.$id.'';
							$reponse=$bdd-> query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
							while ($data =$reponse->fetch())
							{
								unlink ('../upload/'.$data['lib_image']);
							}
							$sql = 'SELECT *
							FROM fichier
							WHERE id_information='.$id.'';
							$reponse=$bdd-> query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
							while ($data =$reponse->fetch())
							{
								unlink ('../upload/'.$data['lib_fichier']);
							}
							
							$req='DELETE FROM information WHERE id_information='.$id.'';
							$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
							
							echo '<div class="alert alert-success">Suppression effectuée avec succès </div>';
							?> 
							<script type="text/javascript">
							window.setTimeout("location=('gestionnaire-table.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",2000);
							</script>
							<?php
						}			
						?>
                        Voulez-vous supprimer cet élément: <?php /*echo $det;*/ echo $data[1] ?> ?
                        <form role="form" method="post" action="">
                            <input type="submit" class="btn btn-default" value="Oui" name="valider"> <a href="gestionnaire-table.php?W9mvyDvFWE5=<?php echo $chaiz; ?>">Non</a>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

<?php 
}
else
{
	header('Location: index.php');
}
?>