<?php
session_start();
include('../connexion.php');
if (!isset($_SESSION['celest']))
{
	header ('Location: index.php');
}
$active='parametre';
if (isset($_GET['W9mvyDvFWE5']))
{
	$chaiz=addslashes($_GET['W9mvyDvFWE5']);
	require_once('active.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">
            	<?php
				// ces div ne sont pas les produits
                if($chaiz!='produit')
				{
                    $sql='SELECT * FROM privilege WHERE lib_privilege="'.$chaiz.'"';
					$reponse=$bdd-> query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
					$data=$reponse->fetch();
					$afficher=$data['afficher_privilege'];
				?>
                <div class="col-lg-2 col-md-1"></div>
                <div class="col-lg-8 col-md-10 col-sm-11 col-xs-12" id="administration">
                    <div id="titro_admin">Ajout <?php echo $afficher ?></div>
                    <?php
				}
                    switch($chaiz)
					{
						case 'type':
						$sql2 = 'SELECT COUNT(*) as nbr FROM selection';
						$reponse2=$bdd->query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
						$data2 =$reponse2->fetch();
						$nbr_selection=$data2[0];
						?>
                        <div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								$nom=addslashes(($_POST['nom']));
								$nombre=addslashes(($_POST['nombre']));
								$fichier=addslashes(($_POST['fichier']));
								$video=addslashes(($_POST['video']));
								$fa=addslashes(($_POST['fa']));

								$date_mise=date('Y-m-d H:i:s');
								
								$nbr_checkbox=0;
								for ($n=1; $n<=$nbr_selection; $n++)
								{
									if (isset($_POST['selection'.$n.'']))
									{
										$checkbox=($_POST['selection'.$n.'']);
										if (!empty($checkbox))
										{
											$nbr_checkbox++;
										}
									}
								}
								if ($nbr_checkbox==0)
								{
									echo '<div class="alert alert-danger">Veuillez choisir au moins une option</div>';
								}
								elseif (empty($nom))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le titre</div>';
								}
								else
								{
									if ($nombre=='')
									{
										//echo '<div class="alert alert-danger">Veuillez renseigner le nombre d\'image</div>';
										$nombre=0;
									}
									if ($fichier=='')
									{
										//echo '<div class="alert alert-danger">Veuillez renseigner le nombre de fichier</div>';
										$fichier=0;
									}
									if ($video=='')
									{
										//echo '<div class="alert alert-danger">Veuillez renseigner le nombre de vidéo</div>';
										$video=0;
									}
									$url=strtolower(str_replace($suppression, $ajouter, $nom));
									$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$nom.'", "'.$nombre.'", "'.$fichier.'", "'.$video.'", "'.$date_mise.'", "'.$_SESSION['celest'].'", "'.$url.'", 0, "'.$fa.'")';
									$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
									
									$sql2= 'SELECT MAX(id_'.$chaiz.') FROM '.$chaiz.'';
									$reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
									$data2=$reponse2->fetch();
									
									$nbr_checkbox=0;
									for ($n=1; $n<=$nbr_selection; $n++)
									{
										if (isset($_POST['selection'.$n]))
										{
											$checkbox=($_POST['selection'.$n]);
											$obliger=($_POST['obliger'.$n]);
											/*$type_slider = 'NULL';
											if(isset($_POST['type_slider'.$n]))
											{
												$type_slider = $_POST['type_slider'.$n];
											}*/
											if (!empty($checkbox))
											{
												$nbr_checkbox++;
												$req='INSERT INTO selection_type VALUES ("'.$checkbox.'", "'.$data2[0].'", "'.$date_mise.'", "'.$date_mise.'", "'.$obliger.'")';
												$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
											}
										}
									}
									echo '<div class="alert alert-success"> ajout effectué avec succès avec '.$nbr_checkbox.' champs</div>';
									?> 
									<script type="text/javascript">
									window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",2500);
									</script>
									<?php
								}
							}			
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                        	<h5>Titre</h5>
							<input autofocus type="text" class="form-control" name="nom" value="<?php if (isset($_POST['valider'])){echo $_POST['nom'];} ?>">
                            <h5>Nombre d'image</h5>
							<input type="text" class="form-control" name="nombre" value="<?php if (isset($_POST['valider'])){echo $_POST['nombre'];} ?>">
                            <h5>Nombre de fichier</h5>
							<input type="text" class="form-control" name="fichier" value="<?php if (isset($_POST['valider'])){echo $_POST['fichier'];} ?>">
                            <h5>Nombre de vidéo</h5>
							<input type="text" class="form-control" name="video" value="<?php if (isset($_POST['valider'])){echo $_POST['video'];} ?>">
							<h5>Font Awesone</h5>
							<input type="text" class="form-control" name="fa" value="<?php if (isset($_POST['valider'])){echo $_POST['fa'];} ?>">
                            <h5>Champs utilisés</h5>
                            <div id="checkbox">
								<?php
                                $i=0;
                                $sql= 'SELECT * FROM selection ORDER BY id_selection ASC';
                                $reponse=$bdd->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
                                while ($data=$reponse->fetch())
                                {
                                    $i++;
                                    ?>
                                    <script type="text/javascript">
									function Change<?php echo $i; ?>()
									{
										if ((document.getElementById('oui<?php echo $i; ?>').checked))
										{
											document.getElementById('rai<?php echo $i; ?>').style.display="block";
										}
										else
										{
											document.getElementById('rai<?php echo $i; ?>').style.display="none";
										}
									}
									</script>
                                    <div id="box-price">
	                                    <input <?php if (isset($_POST['selection'.$i.'']) and isset($_POST['valider'])){echo ' checked';} ?> type="checkbox" name="selection<?php echo $i; ?>" class="checkbox-inline" value="<?php echo $data['id_selection'] ?>" onClick="Change<?php echo $i; ?>()" id="oui<?php echo $i; ?>">
	                                    <?php echo $data['lib_selection'] ?>
                                        <span id="rai<?php echo $i; ?>" style="display:none">
                                        	<select name="obliger<?php echo $i; ?>" class="form-control" id="type_slider">
                                            	<option value="1">1 - Champ obligatoire</option>
                                            	<option value="0">0 - Champ facultatif</option>
				                            </select>
                                            <!-- <input type="text" class="form-control" name="obliger<?php echo $i; ?>" placeholder="Obliger 0/1" id="price" value="<?php if (isset($_POST['valider'])){echo $_POST['old_price'.$i];}?>" onKeypress="if(event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;if(event.which < 45 || event.which > 57) return false;"> -->
                                            <?php
                                            /*if($data[0] == 6)
                                            {
                                            	?>
                                            	<select name="type_slider<?php echo $i; ?>" class="form-control" id="type_slider">
	                                            	<option value="">---------------------</option>
													<?php
													$sql2= 'SELECT * FROM type_slider ORDER BY lib_type_slider ASC';
					                                $reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
					                                while ($data2 =$reponse2->fetch())
					                                {
					                                    if(isset($_POST['valider']) and $_POST['type_slider']==$data2[0])
					                                    {
					                                        echo $cocher=' selected="selected"';
					                                    }
					                                    else
					                                    {
					                                        echo $cocher='';
					                                    }
					                                    echo '<option'.$cocher.' value="'.$data2[0].'">'.$data2['lib_type_slider'].' '.$data2['width_type_slider'].'x'.$data2['height_type_slider'].'</option>';
					                                }
					                                ?>
					                            </select>
                                            	<?php
                                            }*/
                                            ?>
                                        </span>
                                    </div>
                                    <?php
                                }
                                ?>
                            </div>
							<div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="gestionnaire-info.php?W9mvyDvFWE5=<?php echo $chaiz ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
						
						case 'user':
						$sql2 = 'SELECT COUNT(*) as nbr FROM privilege';
						$reponse2=$bdd->query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
						$data2 =$reponse2->fetch();
						$nbr_selection=$data2[0];
						$sql2 = 'SELECT COUNT(*) as nbr FROM type';
						$reponse2=$bdd->query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
						$data2 =$reponse2->fetch();
						$nbr_selection2=$data2[0];
						?>
                        <div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								$login=addslashes(($_POST['login']));
								$type=addslashes(($_POST['type']));
								/*$role=addslashes(($_POST['role']));*/
								$mail=addslashes(($_POST['mail']));
								$bloquer=addslashes(($_POST['bloquer']));
								$mdp1=addslashes(($_POST['mdp1']));
								$mdp2=addslashes(($_POST['mdp2']));
								$date_mise=date('Y-m-d H:i:s');
								
								$sql = 'SELECT count(*) FROM user WHERE mail_user="'.$mail.'"';
								$reponse=$bdd-> query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
								$data =$reponse->fetch();
								$nbr_mail=$data[0];
								
								$nbr_checkbox=0;
								for ($n=1; $n<=$nbr_selection; $n++)
								{
									if (isset($_POST['selection'.$n.'']))
									{
										$checkbox=($_POST['selection'.$n.'']);
										if (!empty($checkbox))
										{
											$nbr_checkbox++;
										}
									}
								}
								
								$nbr_type=0;
								for ($n=1; $n<=$nbr_selection2; $n++)
								{
									if (isset($_POST['type'.$n.'']))
									{
										$checkbox=($_POST['type'.$n.'']);
										if (!empty($checkbox))
										{
											$nbr_type++;
										}
									}
								}
								
								/*if ($nbr_checkbox==0)
								{
									echo '<div class="alert alert-danger">Veuillez choisir au moins un privilège</div>';
								}*/
								/*elseif ($nbr_type==0)
								{
									echo '<div class="alert alert-danger">Veuillez choisir au moins une rubrique</div>';
								}*/
								if (empty($login))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le login</div>';
								}
								elseif (empty($type))
								{
									echo '<div class="alert alert-danger">Veuillez choisir le type d\'utilisateur</div>';
								}
								/*elseif (empty($role))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le role</div>';
								}*/
								elseif (empty($mail))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le Email</div>';
								}
								elseif (empty($bloquer))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le blocage (oui ou non)</div>';
								}
								elseif (empty($mdp1))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le mote de passe</div>';
								}
								elseif (empty($mdp2))
								{
									echo '<div class="alert alert-danger">Veuillez confirmer le mot de passe</div>';
								}
								elseif (!filter_var($mail, FILTER_VALIDATE_EMAIL))
								{
									echo '
									<div class="alert alert-danger">
										<strong>Erreur!</strong> Votre E-mail n\'est pas valide
									</div>';
								}
								elseif ($mdp1!=$mdp2)
								{
									echo '
									<div class="alert alert-danger">
										<strong>Erreur!</strong> Les mots de passe ne correspondent pas
									</div>';
								}
								/*elseif ($nbr_mail>0)
								{
									echo '
									<div class="alert alert-danger">
										<strong>Erreur!</strong> Cet email est déjà enregistré
									</div>';
								}*/
								else
								{
									$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$login.'", "'.$mdp1.'", "'.$mail.'", "0", "1", "'.$date_mise.'", "'.$date_mise.'", "'.$type.'", '.$_SESSION['celest'].', "non", "")';
									$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
									
									$sql2= 'SELECT MAX(id_'.$chaiz.') FROM '.$chaiz.'';
									$reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
									$data2=$reponse2->fetch();
									
									//Ajout privillège de l'utilisateur
									$nbr_checkbox=0;
									for ($n=1; $n<=$nbr_selection; $n++)
									{
										if (isset($_POST['selection'.$n.'']))
										{
											$checkbox=($_POST['selection'.$n.'']);
											if (!empty($checkbox))
											{
												$nbr_checkbox++;
												$req='INSERT INTO user_privilege VALUES ("'.$data2[0].'", "'.$checkbox.'", "'.$date_mise.'", "'.$date_mise.'")';
												$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
											}
										}
									}
									
									//Ajout rubrique à voir par l'utilisateur
									$nbr_checkbox=0;
									for ($n=1; $n<=$nbr_selection2; $n++)
									{
										if (isset($_POST['type'.$n.'']))
										{
											$checkbox=($_POST['type'.$n.'']);
											if (!empty($checkbox))
											{
												$nbr_checkbox++;
												$req='INSERT INTO user_type VALUES ("'.$data2[0].'", "'.$checkbox.'", "'.$date_mise.'", "'.$date_mise.'")';
												$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
											}
										}
									}
									echo '<div class="alert alert-success"> ajout effectué avec succès avec</div>';
									?> 
									<script type="text/javascript">
									window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",2500);
									</script>
									<?php
								}
							}			
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                        	<h5>Login</h5>
							<input autofocus type="text" class="form-control" name="login" value="<?php if (isset($_POST['valider'])){echo $_POST['login'];} ?>">
                        	<h5>Email</h5>
							<input type="text" class="form-control" name="mail" value="<?php if (isset($_POST['valider'])){echo $_POST['mail'];} ?>">
                        	<h5>Type d'utilisateur</h5>
                            <select name="type" class="form-control">
								<?php
								if($developpeur==1)
								{
									$sql2= 'SELECT * FROM type_user ORDER BY lib_type_user ASC';
								}
								else
								{
									$sql2= 'SELECT * FROM type_user WHERE id_type_user<>1 ORDER BY lib_type_user ASC';
								}
                                $reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
                                while ($data2 =$reponse2->fetch())
                                {
                                    if(isset($_POST['valider']) and $_POST['type']==$data2[0])
                                    {
                                        echo $cocher=' selected="selected"';
                                    }
                                    else
                                    {
                                        echo $cocher='';
                                    }
                                    echo '<option'.$cocher.' value="'.$data2[0].'">'.$data2['lib_type_user'].'</option>';
                                }
                                ?>
                            </select>
                        	<h5>Bloquer <span id="span">(1/0)</span></h5>
                            <select name="bloquer" class="form-control">
                            	<option>1</option>
                            	<option>0</option>
                            </select>
                        	<h5>Mot de passe</h5>
							<input type="password" class="form-control" name="mdp1" value="<?php if (isset($_POST['valider'])){echo $_POST['mdp1'];} ?>">
                        	<h5>Confirmation Mot de passe</h5>
							<input type="password" class="form-control" name="mdp2" value="<?php if (isset($_POST['valider'])){echo $_POST['mdp2'];} ?>">
                            <h5>Privilèges</h5>
                            <div id="checkbox">
								<?php
                                $i=0;
								if($developpeur==1)
								{
                                	$sql= 'SELECT * FROM privilege ORDER BY id_privilege ASC';
								}
								else
								{
                                	$sql= 'SELECT * FROM privilege WHERE visible_privilege=1 ORDER BY id_privilege ASC';
								}
								$reponse=$bdd->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
                                while ($data=$reponse->fetch())
                                {
                                    $i++;
                                    ?>
                                    <input <?php if (isset($_POST['selection'.$i.'']) and isset($_POST['valider'])){echo ' checked';} ?> type="checkbox" name="selection<?php echo $i; ?>" class="checkbox-inline" value="<?php echo $data['id_privilege'] ?>">
                                    <?php echo $data['afficher_privilege']; ?>
                                    <?php
                                }
                                ?>
                            </div>
                            <h5>Rubriques</h5>
                            <div id="checkbox">
								<?php
                                $i=0;
                                $sql= 'SELECT * FROM type ORDER BY id_type ASC';
                                $reponse=$bdd->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
                                while ($data=$reponse->fetch())
                                {
                                    $i++;
                                    ?>
                                    <input <?php if (isset($_POST['type'.$i.'']) and isset($_POST['valider'])){echo ' checked';} ?> type="checkbox" name="type<?php echo $i; ?>" class="checkbox-inline" value="<?php echo $data['id_type'] ?>">
                                    <?php echo $data['lib_type'] ?>
                                    <?php
                                }
                                ?>
                            </div>
							<div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="gestionnaire-info.php?W9mvyDvFWE5=<?php echo $chaiz ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
						
						case 'selection':
						?>
						<div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								$afficher=addslashes(($_POST['afficher']));
								$nom=addslashes(($_POST['nom']));
								$privilege=addslashes(($_POST['privilege']));
								if($privilege=='')
								{
									$privilege='NULL';
								}
								echo $privilege;
								$select=addslashes(($_POST['select']));
								$champ=addslashes(($_POST['champ']));
								$date_mise=date('Y-m-d H:i:s');
								if(empty($nom))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le titre</div>';
								}
								elseif(empty($afficher))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le nom à afficher dans l\'administration</div>';
								}
								elseif(empty($champ))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le type</div>';
								}
								else
								{
									$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$nom.'", "'.$champ.'", "'.$date_mise.'", '.$_SESSION['celest'].', '.$privilege.', "'.$afficher.'", "'.$select.'", "z")';
									$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
									echo '<div class="alert alert-success"> ajout effectué avec succès</div>';
									?> 
									<script type="text/javascript">
									window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",1000);
									</script>
									<?php
								}
							}			
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                        	<h5>Titre</h5>
							<input autofocus type="text" class="form-control" name="nom" value="<?php if (isset($_POST['valider'])){echo $_POST['nom'];} ?>">
                            <h5>Affichage dans l'administration</h5>
							<input type="text" class="form-control" name="afficher" value="<?php if (isset($_POST['valider'])){echo $_POST['afficher'];} ?>">
                            <h5>Type de select <span id="span">(table / classique)</span></h5>
							<input type="text" class="form-control" name="select" value="<?php if (isset($_POST['valider'])){echo $_POST['select'];} ?>">
                            <h5>Type de champ</h5>
                            <select name="champ" class="form-control">
								<?php
                                $sql2 = "SELECT * FROM champ ORDER BY lib_champ ASC";
                                $reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
                                while ($data2 =$reponse2->fetch())
                                {
                                    if(isset($_POST['valider']) and $_POST['champ']==$data2[0])
                                    {
                                        echo $cocher=' selected="selected"';
                                    }
                                    else
                                    {
                                        echo $cocher='';
                                    }
                                    echo '<option'.$cocher.' value="'.$data2[0].'">'.$data2['lib_champ'].'</option>';
                                }
                                ?>
                            </select>
                            <h5>Table (Privilege)</h5>
                            <select name="privilege" class="form-control">
                            	<option value="">-----------------------------------------</option>
								<?php
                                $sql2 = "SELECT * FROM privilege ORDER BY lib_privilege ASC";
                                $reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
                                while($data2 =$reponse2->fetch())
                                {
                                    if(isset($_POST['valider']) and $_POST['privilege']==$data2[0])
                                    {
                                        echo $cocher=' selected="selected"';
                                    }
                                    else
                                    {
                                        echo $cocher='';
                                    }
                                    echo '<option'.$cocher.' value="'.$data2[0].'">'.$data2['lib_privilege'].'</option>';
                                }
                                ?>
                            </select>
							<div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="gestionnaire-info.php?W9mvyDvFWE5=<?php echo $chaiz ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
						
						case 'typeinfo':
						?>
						<div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								$nom=addslashes(($_POST['nom']));
								$type=addslashes(($_POST['type']));
								$present=addslashes(($_POST['present']));
								$fa=addslashes(($_POST['fa']));
					
								$name_img=$_FILES['tof']['name'];
								$type_img=$_FILES['tof']['type'];
								$size_img=$_FILES['tof']['size'];
								$temp_img=$_FILES['tof']['tmp_name'];
								$error_img=$_FILES['tof']['error'];
								
								$extension=strrchr($name_img,'.');
								$date_mise=date('Y-m-d H:i:s');
								if (empty($nom))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le titre</div>';
								}
								elseif (empty($type))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner la rubrique</div>';
								}
								else
								{
									$url=strtolower(str_replace($suppression, $ajouter, $nom));
									if ($error_img==0)
									{
										if ($extension=='.jpg' or $extension=='.png' or $extension=='.jpeg' or $extension=='.gif' or $extension=='.bmp' or $extension=='.JPG' or $extension=='.PNG' or $extension=='.JPEG' or $extension=='.GIF' or $extension=='.BMP')
										{
											$lien_img=$date_img.'777ng_koben'.$extension;
											move_uploaded_file($temp_img, "../upload/".$lien_img);
										
											$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$nom.'", '.$type.', "'.$date_mise.'", '.$_SESSION['celest'].', "'.$url.'", "'.$lien_img.'", "'.$present.'", "'.$fa.'")';
											$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
											echo '<div class="alert alert-success"> Ajout effectué avec succès</div>';
											?>
											<script type="text/javascript">
											window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",1000);
											</script>
											<?php
										}
										else
										{
											echo '<div class="alert alert-danger">Format Incorrect </div>';
										}
									}
									elseif($error_img==4)
									{
										$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$nom.'", '.$type.', "'.$date_mise.'", '.$_SESSION['celest'].', "'.$url.'", "", "'.$present.'", "'.$fa.'")';
										$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
										echo '<div class="alert alert-success"> Ajout effectué avec succès</div>';
										?>
										<script type="text/javascript">
										window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",2000);
										</script>
										<?php
									}
									else
									{
										echo '<div class="alert alert-danger">Erreur de Transmission !</div>';
									}
								}
							}			
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                        	<h5>Titre *</h5>
							<input autofocus type="text" class="form-control" name="nom" value="<?php if (isset($_POST['valider'])){echo $_POST['nom'];} ?>">
							<h5>Font Awesone</h5>
							<input type="text" class="form-control" name="fa" value="<?php if (isset($_POST['valider'])){echo $_POST['fa'];} ?>">
                        	<h5>Rubrique *</h5>
                            <select name="type" class="form-control">
								<?php
                                $sql2 = "SELECT * FROM type ORDER BY lib_type ASC";
                                $reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
                                while ($data2 =$reponse2->fetch())
                                {
                                    if(isset($_POST['valider']) and $_POST['type']==$data2[0])
                                    {
                                        echo $cocher=' selected="selected"';
                                    }
                                    else
                                    {
                                        echo $cocher='';
                                    }
                                    echo '<option'.$cocher.' value="'.$data2[0].'">'.$data2['lib_type'].'</option>';
                                }
                                ?>
                            </select>
                            <h5>Description</h5>
							<textarea class="form-control" id="present" name="present"><?php if (isset($_POST['valider'])){echo $_POST['present'];} ?></textarea>
                            <script>
								CKEDITOR.replace('present');
							</script>
                            <h5>Image</h5>
                            <input type="file" class="form-control" name="tof">
							<div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="gestionnaire-info.php?W9mvyDvFWE5=<?php echo $chaiz ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
						
						case 'categorie':
						?>
						<div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								$nom=addslashes(($_POST['nom']));
								$type=addslashes(($_POST['type']));
								$typeinfo=addslashes(($_POST['typeinfo']));
								$present=addslashes(($_POST['present']));
					
								$name_img=$_FILES['tof']['name'];
								$type_img=$_FILES['tof']['type'];
								$size_img=$_FILES['tof']['size'];
								$temp_img=$_FILES['tof']['tmp_name'];
								$error_img=$_FILES['tof']['error'];
								
								$extension=strrchr($name_img,'.');
								$date_mise=date('Y-m-d H:i:s');
								if (empty($nom))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le titre</div>';
								}
								elseif (empty($type))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le type table</div>';
								}
								elseif (empty($typeinfo))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le type d\'information</div>';
								}
								else
								{
									$url=strtolower(str_replace($suppression, $ajouter, $nom));
									if ($error_img==0)
									{
										if ($extension=='.jpg' or $extension=='.png' or $extension=='.jpeg' or $extension=='.gif' or $extension=='.bmp' or $extension=='.JPG' or $extension=='.PNG' or $extension=='.JPEG' or $extension=='.GIF' or $extension=='.BMP')
										{
											$lien_img=$date_img.'777ng_koben'.$extension;
											move_uploaded_file($temp_img, "../upload/".$lien_img);
										
											$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$nom.'", '.$type.', "'.$date_mise.'", '.$_SESSION['celest'].', "'.$url.'", "'.$lien_img.'", "'.$present.'", '.$typeinfo.')';
											$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
											echo '<div class="alert alert-success"> Ajout effectué avec succès</div>';
											?>
											<script type="text/javascript">
											window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",1000);
											</script>
											<?php
										}
										else
										{
											echo '<div class="alert alert-danger">Format Incorrect </div>';
										}
									}
									elseif($error_img==4)
									{
										$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$nom.'", '.$type.', "'.$date_mise.'", '.$_SESSION['celest'].', "'.$url.'", "", "'.$present.'", '.$typeinfo.')';
										$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
										echo '<div class="alert alert-success"> Ajout effectué avec succès</div>';
										?>
										<script type="text/javascript">
										window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",1000);
										</script>
										<?php
									}
									else
									{
										echo '<div class="alert alert-danger">Erreur de Transmission !</div>';
									}
								}
							}			
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                        	<h5>Titre</h5>
							<input autofocus type="text" class="form-control" name="nom" value="<?php if (isset($_POST['valider'])){echo $_POST['nom'];} ?>">
                        	<h5>Type d'Information</h5>
                            <select name="typeinfo" class="form-control">
                            	<!--<option value="">-----------------------</option>-->
								<?php
                                $sql2 = "SELECT * FROM typeinfo ORDER BY lib_typeinfo ASC";
                                $reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
                                while ($data2 =$reponse2->fetch())
                                {
                                    if(isset($_POST['valider']) and $_POST['typeinfo']==$data2[0])
                                    {
                                        echo $cocher=' selected="selected"';
                                    }
                                    else
                                    {
                                        echo $cocher='';
                                    }
                                    echo '<option'.$cocher.' value="'.$data2[0].'">'.$data2['lib_typeinfo'].'</option>';
                                }
                                ?>
                            </select>
                        	<h5>Type table</h5>
                            <select name="type" class="form-control">
                            	<!--<option value="">-----------------------</option>-->
								<?php
                                $sql2 = "SELECT * FROM type ORDER BY lib_type ASC";
                                $reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
                                while ($data2 =$reponse2->fetch())
                                {
                                    if(isset($_POST['valider']) and $_POST['type']==$data2[0])
                                    {
                                        echo $cocher=' selected="selected"';
                                    }
                                    else
                                    {
                                        echo $cocher='';
                                    }
                                    echo '<option'.$cocher.' value="'.$data2[0].'">'.$data2['lib_type'].'</option>';
                                }
                                ?>
                            </select>
                            <h5>Description</h5>
							<textarea class="form-control" id="present" name="present"><?php if (isset($_POST['valider'])){echo $_POST['present'];} ?></textarea>
                            <script>
								CKEDITOR.replace('present');
							</script>
                            <h5>Image</h5>
                            <input type="file" class="form-control" name="tof">
							<div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="gestionnaire-info.php?W9mvyDvFWE5=<?php echo $chaiz ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
						
						case 'coordonnee':
						?>
						<div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								$fa=addslashes(($_POST['fa']));
								$nom=addslashes(($_POST['nom']));
								$valeur=addslashes(($_POST['valeur']));
								$date_mise=date('Y-m-d H:i:s');
								if (empty($nom))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le titre</div>';
								}
								elseif (empty($valeur))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner la valeur</div>';
								}
								elseif (empty($fa))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner font awesome</div>';
								}
								else
								{
									$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$nom.'", "'.$valeur.'", "'.$fa.'", "'.$date_mise.'", '.$_SESSION['celest'].')';
									$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
									echo '<div class="alert alert-success"> ajout effectué avec succès</div>';
									?> 
									<script type="text/javascript">
									window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",1000);
									</script>
									<?php
								}
							}			
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                        	<h5>Titre</h5>
							<input autofocus type="text" class="form-control" name="nom" value="<?php if (isset($_POST['valider'])){echo $_POST['nom'];} ?>">
                        	<h5>Valeur</h5>
							<input autofocus type="text" class="form-control" name="valeur" value="<?php if (isset($_POST['valider'])){echo $_POST['valeur'];} ?>">
                        	<h5>Font awesome</h5>
							<input autofocus type="text" class="form-control" name="fa" value="<?php if (isset($_POST['valider'])){echo $_POST['fa'];} ?>">
                            <!--<h5>Langue</h5>
                            	<select name="type" class="form-control">
								<?php
                                /*$sql2 = "SELECT * FROM langue ORDER BY lib_langue ASC";
                                $reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
                                while ($data2 =$reponse2->fetch())
                                {
                                    if(isset($_POST['valider']) and $_POST['type']==$data2['lib_langue'])
                                    {
                                        echo $cocher=' selected="selected"';
                                    }
                                    else
                                    {
                                        echo $cocher='';
                                    }
                                    echo '<option'.$cocher.' value="'.$data2[0].'">'.$data2['lib_langue'].'</option>';
                                }*/
                                ?>
                            </select>-->
							<div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="gestionnaire-info.php?W9mvyDvFWE5=<?php echo $chaiz ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
						
						case 'agence':
						?>
						<div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								if(isset($_SESSION['langue']))
								{
									$langue=$_SESSION['langue'];
								}
								else
								{
									$langue="NULL";
								}
								$nom=addslashes(($_POST['nom']));
								$present=addslashes(($_POST['present']));
					
								$name_img=$_FILES['tof']['name'];
								$type_img=$_FILES['tof']['type'];
								$size_img=$_FILES['tof']['size'];
								$temp_img=$_FILES['tof']['tmp_name'];
								$error_img=$_FILES['tof']['error'];
								
								$extension=strrchr($name_img,'.');
								$date_mise=date('Y-m-d H:i:s');

								if (empty($nom))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le titre</div>';
								}
								else
								{
									//avoir l'url
									$url=strtolower(str_replace($suppression, $ajouter, $nom));
									if ($error_img==0)
									{
										if ($extension=='.jpg' or $extension=='.png' or $extension=='.jpeg' or $extension=='.gif' or $extension=='.bmp' or $extension=='.JPG' or $extension=='.PNG' or $extension=='.JPEG' or $extension=='.GIF' or $extension=='.BMP')
										{
											$lien_img=$date_img.'777ng_koben'.$extension;
											move_uploaded_file($temp_img, "../upload/".$lien_img);
										
											$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$nom.'", "'.$present.'", "'.$lien_img.'", '.$langue.', "'.$date_mise.'", '.$_SESSION['celest'].', "'.$url.'")';
											$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
											echo '<div class="alert alert-success"> Ajout effectué avec succès</div>';
											?>
											<script type="text/javascript">
											window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",1000);
											</script>
											<?php
										}
										else
										{
											echo '<div class="alert alert-danger">Format Incorrect </div>';
										}
									}
									elseif($error_img==4)
									{
										$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$nom.'", "'.$present.'", "", '.$langue.', "'.$date_mise.'", '.$_SESSION['celest'].', "'.$url.'")';
										$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
										echo '<div class="alert alert-success"> Ajout effectué avec succès</div>';
										?>
										<script type="text/javascript">
										window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",1000);
										</script>
										<?php
									}
									else
									{
										echo '<div class="alert alert-danger">Erreur de Transmission !</div>';
									}
								}
							}			
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                        	<h5>Titre</h5>
							<input autofocus type="text" class="form-control" name="nom" value="<?php if (isset($_POST['valider'])){echo $_POST['nom'];} ?>">
                        	<h5>Description</h5>
							<textarea class="form-control" id="present" name="present"><?php if (isset($_POST['valider'])){echo $_POST['present'];} ?></textarea>
                            <!-- <script>
								CKEDITOR.replace('present');
							</script> -->
                            <h5>Image</h5>
                            <input type="file" class="form-control" name="tof">
							<div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="gestionnaire-info.php?W9mvyDvFWE5=<?php echo $chaiz ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
												
						case 'langue':
						?>
						<div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								$nom=addslashes(($_POST['nom']));
					
								$name_img=$_FILES['tof']['name'];
								$type_img=$_FILES['tof']['type'];
								$size_img=$_FILES['tof']['size'];
								$temp_img=$_FILES['tof']['tmp_name'];
								$error_img=$_FILES['tof']['error'];
								
								$extension=strrchr($name_img,'.');
								$date_mise=date('Y-m-d H:i:s');

								if (empty($nom))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le titre</div>';
								}
								else
								{
									if ($error_img==0)
									{
										if ($extension=='.jpg' or $extension=='.png' or $extension=='.jpeg' or $extension=='.gif' or $extension=='.bmp' or $extension=='.JPG' or $extension=='.PNG' or $extension=='.JPEG' or $extension=='.GIF' or $extension=='.BMP')
										{
											$lien_img=$date_img.'777ng_koben'.$extension;
											move_uploaded_file($temp_img, "../upload/".$lien_img);
										
											$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$nom.'", "'.$lien_img.'", "'.$date_mise.'", '.$_SESSION['celest'].')';
											$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
											echo '<div class="alert alert-success"> Ajout effectué avec succès</div>';
											?>
											<script type="text/javascript">
											window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",1000);
											</script>
											<?php
										}
										else
										{
											echo '<div class="alert alert-danger">Format Incorrect </div>';
										}
									}
									elseif($error_img==4)
									{
										echo '<div class="alert alert-danger">Pas d\'image !</div>';
									}
									else
									{
										echo '<div class="alert alert-danger">Erreur de Transmission !</div>';
									}
								}
							}			
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                        	<h5>Titre</h5>
							<input autofocus type="text" class="form-control" name="nom" value="<?php if (isset($_POST['valider'])){echo $_POST['nom'];} ?>">
                            <h5>Image</h5>
                            <input type="file" class="form-control" name="tof">
							<div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="gestionnaire-info.php?W9mvyDvFWE5=<?php echo $chaiz ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
						
						case 'privilege':
						?>
						<div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								$nom=addslashes(($_POST['nom']));
								$visible=addslashes(($_POST['visible']));
								$afficher=addslashes(($_POST['afficher']));
								$position=addslashes(($_POST['position']));
								$fa=addslashes(($_POST['fa']));
								$date_mise=date('Y-m-d H:i:s');
								if (empty($nom))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le titre</div>';
								}
								elseif($visible=='')
								{
									echo '<div class="alert alert-danger">Veuillez renseigner la visibilité</div>';
								}
								elseif (empty($afficher))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le nom à afficher dans l\'administration</div>';
								}
								elseif ($position=='')
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le positionnement</div>';
								}
								else
								{
									$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$nom.'", "'.$date_mise.'", "'.$position.'", '.$_SESSION['celest'].', "'.$afficher.'", '.$visible.',"'.$fa.'")';
									$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
									echo '<div class="alert alert-success"> ajout effectué avec succès</div>';
									?> 
									<script type="text/javascript">
									window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",2500);
									</script>
									<?php
								}
							}			
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                        	<h5>Titre</h5>
							<input autofocus type="text" class="form-control" name="nom" value="<?php if (isset($_POST['valider'])){echo $_POST['nom'];} ?>">
                        	<h5>Affichage dans l'administration</h5>
							<input type="text" class="form-control" name="afficher" value="<?php if (isset($_POST['valider'])){echo $_POST['afficher'];} ?>">
                        	<h5>Positionement <span id="span_privilege">utilisateur/parametre/visiteur/droite</span></h5>
							<input type="text" class="form-control" name="position" value="<?php if (isset($_POST['valider'])){echo $_POST['position'];} ?>">
                            <h5>Visible dans l'ajout d'utilisateur <span id="span">pour l'administrateur</span></h5>
							<input type="text" class="form-control" name="visible" value="<?php if (isset($_POST['valider'])){echo $_POST['visible'];} ?>">
							<h5>Icon Font Awesone</h5>
                            <input type="text" class="form-control" name="fa" value="<?php if(isset($_POST['valider'])){echo $_POST['fa'];} ?>">
							<div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="gestionnaire-info.php?W9mvyDvFWE5=<?php echo $chaiz ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
						
						case 'champ':
						case 'type_user':
						case 'commune':
						case 'contrat':
						case 'equipement':
						?>
						<div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								$nom=addslashes(($_POST['nom']));
								$date_mise=date('Y-m-d H:i:s');
								if (empty($nom))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le titre</div>';
								}
								else
								{
									$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$nom.'", "'.$date_mise.'", '.$_SESSION['celest'].')';
									$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
									echo '<div class="alert alert-success"> ajout effectué avec succès</div>';
									?> 
									<script type="text/javascript">
									window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",2500);
									</script>
									<?php
								}
							}			
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                        	<h5>Titre</h5>
							<input autofocus type="text" class="form-control" name="nom" value="<?php if (isset($_POST['valider'])){echo $_POST['nom'];} ?>">
							<div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="gestionnaire-info.php?W9mvyDvFWE5=<?php echo $chaiz ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
						
						case 'type_slider':
						?>
						<div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								$nom=addslashes(($_POST['nom']));
								$width=addslashes(($_POST['width']));
								$height=addslashes(($_POST['height']));
								$date_mise=date('Y-m-d H:i:s');
								if (empty($nom))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le titre</div>';
								}
								elseif (empty($width))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner la largeur</div>';
								}
								elseif (empty($height))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner la hauteur</div>';
								}
								else
								{
									$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$nom.'", "'.$width.'", "'.$height.'", "'.$date_mise.'", '.$_SESSION['celest'].')';
									$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
									echo '<div class="alert alert-success"> ajout effectué avec succès</div>';
									?> 
									<script type="text/javascript">
									window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",2500);
									</script>
									<?php
								}
							}			
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                        	<h5>Titre</h5>
							<input autofocus type="text" class="form-control" name="nom" value="<?php if (isset($_POST['valider'])){echo $_POST['nom'];} ?>">
                        	<h5>Largeur</h5>
							<input type="text" class="form-control" name="width" value="<?php if (isset($_POST['valider'])){echo $_POST['width'];} ?>">
                        	<h5>Hauteur</h5>
							<input type="text" class="form-control" name="height" value="<?php if (isset($_POST['valider'])){echo $_POST['height'];} ?>">
							<div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="gestionnaire-info.php?W9mvyDvFWE5=<?php echo $chaiz ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
						
						case 'slider':
						?>
						<div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								$nom=addslashes(($_POST['nom']));
								$dimension=addslashes(($_POST['dimension']));

								$name_img=$_FILES['tof']['name'];
								$type_img=$_FILES['tof']['type'];
								$size_img=$_FILES['tof']['size'];
								$temp_img=$_FILES['tof']['tmp_name'];
								$error_img=$_FILES['tof']['error'];
								$extension=strrchr($name_img,'.');
								$date_mise=date('Y-m-d H:i:s');

								/*if (empty($nom))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le titre</div>';
								}
								else
								{*/
									if ($error_img==0)
									{
										if ($extension=='.jpg' or $extension=='.png' or $extension=='.jpeg' or $extension=='.gif' or $extension=='.bmp' or $extension=='.JPG' or $extension=='.PNG' or $extension=='.JPEG' or $extension=='.GIF' or $extension=='.BMP')
										{
											$sql2 = 'SELECT * FROM type_slider WHERE id_type_slider='.$dimension.'';
											$reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
											$data2 =$reponse2->fetch();
											
											$size2=getimagesize($temp_img);
											$width=$size2[0];
											$height=$size2[1];
											if($width==$data2['width_type_slider'] and $height==$data2['height_type_slider'])
											{
												$lien_img=$date_img.'777ng_koben'.$extension;
												move_uploaded_file($temp_img, "../upload/".$lien_img);
												$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$lien_img.'", "'.$nom.'", "'.$date_mise.'", '.$_SESSION['celest'].', '.$dimension.')';
												$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
												echo '<div class="alert alert-success"> Ajout effectué avec succès</div>';
												?>
												<script type="text/javascript">
												window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",0);
												</script>
												<?php
											}
											else
											{
												echo '<div class="alert alert-danger">Respectez les dimensions de l\'image ('.$data2['width_type_slider'].'x'.$data2['height_type_slider'].') !</div>';
											}
										}
										else
										{
											echo '<div class="alert alert-danger">Format de l\'image Incorrect !</div>';
										}
									}
									elseif($error_img==4)
									{
										echo '<div class="alert alert-danger">Pas d\'image sélectionnée !</div>';
									}
									else
									{
										echo '<div class="alert alert-danger">Erreur de Transmission !</div>';
									}
								//}
							}			
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                        	<h5>Lien web</h5>
							<input autofocus type="text" class="form-control" name="nom" value="<?php if (isset($_POST['valider'])){echo $_POST['nom'];} ?>">
                        	<h5>Image</h5>
							<input type="file" class="form-control" name="tof">
                            <h5>dimension</h5>
                            <select name="dimension" class="form-control">
								<?php
                                $sql2 = "SELECT * FROM type_slider ORDER BY lib_type_slider ASC";
                                $reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
                                while ($data2 =$reponse2->fetch())
                                {
                                    if(isset($_POST['valider']) and $_POST['dimension']==$data2[0])
                                    {
                                        echo $cocher=' selected="selected"';
                                    }
                                    else
                                    {
                                        echo $cocher='';
                                    }
                                    echo '<option'.$cocher.' value="'.$data2[0].'">'.$data2['lib_type_slider'].' ('.$data2['width_type_slider'].'x'.$data2['height_type_slider'].')</option>';
                                }
                                ?>
                            </select>
							<div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="gestionnaire-info.php?W9mvyDvFWE5=<?php echo $chaiz ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
						
						case 'slider2':
						?>
						<div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								$nom=addslashes(($_POST['nom']));
								$lien=addslashes(($_POST['lien']));
								$url=addslashes(($_POST['url']));
								$present=addslashes(($_POST['present']));
								$dimension=addslashes(($_POST['dimension']));

								$name_img=$_FILES['tof']['name'];
								$type_img=$_FILES['tof']['type'];
								$size_img=$_FILES['tof']['size'];
								$temp_img=$_FILES['tof']['tmp_name'];
								$error_img=$_FILES['tof']['error'];
								$extension=strrchr($name_img,'.');
								
								$name_caroussel=$_FILES['caroussel']['name'];
								$type_caroussel=$_FILES['caroussel']['type'];
								$size_caroussel=$_FILES['caroussel']['size'];
								$temp_caroussel=$_FILES['caroussel']['tmp_name'];
								$error_caroussel=$_FILES['caroussel']['error'];
								$extension_caroussel=strrchr($name_caroussel,'.');
								$date_mise=date('Y-m-d H:i:s');

								if (empty($nom))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le titre</div>';
								}
								elseif (empty($lien))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le titre du lien</div>';
								}
								/*elseif (empty($url))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner l\'url</div>';
								}*/
								else
								{
									if ($error_caroussel==0)
									{
										if ($extension_caroussel=='.jpg' or $extension_caroussel=='.png' or $extension_caroussel=='.jpeg' or $extension_caroussel=='.gif' or $extension_caroussel=='.bmp' or $extension_caroussel=='.JPG' or $extension_caroussel=='.PNG' or $extension_caroussel=='.JPEG' or $extension_caroussel=='.GIF' or $extension_caroussel=='.BMP')
										{
											$sql2 = 'SELECT * FROM type_slider WHERE id_type_slider='.$dimension.'';
											$reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
											$data2 =$reponse2->fetch();
											
											$size2=getimagesize($temp_caroussel);
											$width=$size2[0];
											$height=$size2[1];
											if($width==$data2['width_type_slider'] and $height==$data2['height_type_slider'])
											{
												$lien_caroussel=$date_img.'777ng_koben'.$extension_caroussel;
												move_uploaded_file($temp_caroussel, "../upload/".$lien_caroussel);
												
												if ($extension=='.jpg' or $extension=='.png' or $extension=='.jpeg' or $extension=='.gif' or $extension=='.bmp' or $extension=='.JPG' or $extension_caroussel=='.PNG' or $extension=='.JPEG' or $extension=='.GIF' or $extension=='.BMP')
												{
													$lien_img=$date_img.'777ng_koben'.$extension;
													move_uploaded_file($temp_img, "../upload/".$lien_img);
												}
												else
												{
													$lien_img='';
												}
												$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$nom.'", "'.$lien_caroussel.'", "'.$lien_img.'", "'.$present.'", "'.$lien.'", "'.$url.'", "'.$date_mise.'", '.$_SESSION['celest'].', '.$dimension.')';
												$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
												echo '<div class="alert alert-success"> Ajout effectué avec succès</div>';
												?>
												<script type="text/javascript">
												window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",0);
												</script>
												<?php
											}
											else
											{
												echo '<div class="alert alert-danger">Respectez les dimensions de l\'image ('.$data2['width_type_slider'].'x'.$data2['height_type_slider'].') !</div>';
											}
										}
										else
										{
											echo '<div class="alert alert-danger">Format de l\'image Incorrect !</div>';
										}
									}
									elseif($error_img==4)
									{
										echo '<div class="alert alert-danger">Pas d\'image sélectionnée !</div>';
									}
									else
									{
										echo '<div class="alert alert-danger">Erreur de Transmission !</div>';
									}
								}
							}			
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                        	<h5>Titre</h5>
							<input type="text" class="form-control" name="nom" value="<?php if (isset($_POST['valider'])){echo $_POST['nom'];} ?>">
                            <h5>Titre lien</h5>
							<input type="text" class="form-control" name="lien" value="<?php if (isset($_POST['valider'])){echo $_POST['lien'];} ?>">
                            <h5>Url</h5>
							<input type="text" class="form-control" name="url" value="<?php if (isset($_POST['valider'])){echo $_POST['url'];} ?>">
                            <h5>Description</h5>
							<textarea class="form-control" id="present" name="present"><?php if (isset($_POST['valider'])){echo $_POST['present'];} ?></textarea>
                            <script>
								CKEDITOR.replace('present');
							</script>
                        	<h5>Caroussel</h5>
							<input type="file" class="form-control" name="caroussel">
                        	<h5>Image</h5>
							<input type="file" class="form-control" name="tof">
                            <h5>dimension</h5>
                            <select name="dimension" class="form-control">
								<?php
                                $sql2 = "SELECT * FROM type_slider ORDER BY lib_type_slider ASC";
                                $reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
                                while ($data2 =$reponse2->fetch())
                                {
                                    if(isset($_POST['valider']) and $_POST['dimension']==$data2[0])
                                    {
                                        echo $cocher=' selected="selected"';
                                    }
                                    else
                                    {
                                        echo $cocher='';
                                    }
                                    echo '<option'.$cocher.' value="'.$data2[0].'">'.$data2['lib_type_slider'].' ('.$data2['width_type_slider'].'x'.$data2['height_type_slider'].')</option>';
                                }
                                ?>
                            </select>
							<div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="gestionnaire-info.php?W9mvyDvFWE5=<?php echo $chaiz ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
						
						case 'image':
						$id=addslashes($_GET['id']);
						$retour=addslashes($_GET['retour']);
						?>
						<div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								$name_img=$_FILES['tof']['name'];
								$type_img=$_FILES['tof']['type'];
								$size_img=$_FILES['tof']['size'];
								$temp_img=$_FILES['tof']['tmp_name'];
								$error_img=$_FILES['tof']['error'];
								$extension=strrchr($name_img,'.');
								$date_mise=date('Y-m-d H:i:s');
								
								if ($error_img==0)
								{
									if ($extension=='.jpg' or $extension=='.png' or $extension=='.jpeg' or $extension=='.gif' or $extension=='.bmp' or $extension=='.JPG' or $extension=='.PNG' or $extension=='.JPEG' or $extension=='.GIF' or $extension=='.BMP')
									{
										$size2=getimagesize($temp_img);
										$width=$size2[0];
										$height=$size2[1];
										$lien_img=$date_img.'777ng_koben'.$extension;
										move_uploaded_file($temp_img, "../upload/".$lien_img);
										$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$lien_img.'", "'.$date_mise.'", "'.$id.'", 1)';
										$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
										echo '<div class="alert alert-success"> Ajout effectué avec succès</div>';
										?>
										<script type="text/javascript">
										window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",2500);
										</script>
										<?php
									}
									else
									{
										echo '<div class="alert alert-danger">Format de l\'image Incorrect !</div>';
									}
								}
								elseif($error_img==4)
								{
									echo '<div class="alert alert-danger">Pas d\'image sélectionnée !</div>';
								}
								else
								{
									echo '<div class="alert alert-danger">Erreur de Transmission !</div>';
								}
							}			
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                        	<h5>Image</h5>
							<input type="file" class="form-control" name="tof">
							<div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="afficher-table.php?W9mvyDvFWE5=<?php echo $retour ?>&QYtgoGbhhd=<?php echo $id ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
						
						case 'agences':
						?>
						<div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								$nom=addslashes(($_POST['nom']));
								$ville=addslashes(($_POST['ville']));
								$longitude=addslashes(($_POST['longitude']));
								$latitude=addslashes(($_POST['latitude']));
								$pays=addslashes(($_POST['pays']));
								$date_mise=date('Y-m-d H:i:s');
								if (empty($nom))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le nom</div>';
								}
								elseif (empty($ville))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner la ville</div>';
								}
								elseif (empty($pays))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner la pays</div>';
								}
								else
								{
									$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$nom.'", "'.$ville.'", "'.$latitude.'", "'.$longitude.'", "'.$date_mise.'", '.$_SESSION['celest'].', '.$pays.')';
									$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
									echo '<div class="alert alert-success"> ajout effectué avec succès</div>';
									?> 
									<script type="text/javascript">
									window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",2000);
									</script>
									<?php
								}
							}			
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                        	<h5>Nom</h5>
							<input autofocus type="text" class="form-control" name="nom" value="<?php if (isset($_POST['valider'])){echo $_POST['nom'];} ?>">
                            <h5>Ville</h5>
							<input type="text" class="form-control" name="ville" value="<?php if (isset($_POST['valider'])){echo $_POST['ville'];} ?>">
                            <h5>Longitude</h5>
							<input type="text" class="form-control" name="longitude" value="<?php if (isset($_POST['valider'])){echo $_POST['longitude'];} ?>">
                            <h5>Latitude</h5>
							<input type="text" class="form-control" name="latitude" value="<?php if (isset($_POST['valider'])){echo $_POST['latitude'];} ?>">
                            <h5>Pays</h5>
                            <select name="pays" class="form-control">
								<?php
                                $sql2 = "SELECT * FROM pays ORDER BY nom_fr_fr ASC";
                                $reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
                                while ($data2 =$reponse2->fetch())
                                {
                                    if($data2[0]==110)
                                    {
                                        echo $cocher=' selected="selected"';
                                    }
                                    else
                                    {
                                        echo $cocher='';
                                    }
                                    echo '<option'.$cocher.' value="'.$data2[0].'">'.$data2['nom_fr_fr'].'</option>';
                                }
                                ?>
                            </select>
							<div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="gestionnaire-info.php?W9mvyDvFWE5=<?php echo $chaiz ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
						
						case 'agent':
						?>
						<div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								$nom=addslashes(($_POST['nom']));
								$prenom=addslashes(($_POST['prenom']));
								$login=addslashes(($_POST['login']));
								$mail=addslashes(($_POST['mail']));
								$tel=addslashes(($_POST['tel']));
								$adresse=addslashes(($_POST['adresse']));
								$etat=addslashes(($_POST['etat']));
								$agence=addslashes(($_POST['agence']));
								$mdp1=addslashes(($_POST['mdp1']));
								$mdp2=addslashes(($_POST['mdp2']));
								$date_mise=date('Y-m-d H:i:s');
								
								$sql = 'SELECT count(*) FROM agent WHERE mail_agent="'.$mail.'"';
								$reponse=$bdd-> query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
								$data =$reponse->fetch();
								$nbr_mail=$data[0];
								if (empty($nom))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le nom</div>';
								}
								elseif (empty($login))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le login</div>';
								}
								elseif (empty($mail))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le mail</div>';
								}
								elseif (empty($tel))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le téléphone</div>';
								}
								elseif (empty($etat))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner l\'état</div>';
								}
								elseif (empty($agence))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner l\'agence</div>';
								}
								elseif (empty($mdp1))
								{
									echo '
									<div class="alert alert-danger">
										<strong>Erreur!</strong> Veuillez renseigner le mot de passe
									</div>';
								}
								elseif (empty($mdp2))
								{
									echo '
									<div class="alert alert-danger">
										<strong>Erreur!</strong> Veuillez confirmer le mot de passe
									</div>';
								}
								elseif (!filter_var($mail, FILTER_VALIDATE_EMAIL))
								{
									echo '
									<div class="alert alert-danger">
										<strong>Erreur!</strong> Votre E-mail n\'est pas valide
									</div>';
								}
								elseif ($mdp1!=$mdp2)
								{
									echo '
									<div class="alert alert-danger">
										<strong>Erreur!</strong> Les mots de passe ne correspondent pas
									</div>';
								}
								elseif ($nbr_mail>0)
								{
									echo '
									<div class="alert alert-danger">
										<strong>Erreur!</strong> Cet e-mail est déjà enregistré
									</div>';
								}
								else
								{
									$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$nom.'", "'.$prenom.'", "'.$login.'", "'.md5($mdp1).'", "'.$mail.'", "'.$tel.'", "'.$adresse.'", "'.$etat.'", "'.$date_mise.'", '.$_SESSION['celest'].', '.$agence.', 0, NULL)';
									$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
									echo '<div class="alert alert-success"> ajout effectué avec succès</div>';
									?> 
									<script type="text/javascript">
									window.setTimeout("location=('ajouter-info.php?W9mvyDvFWE5=<?php echo $chaiz; ?>');",2000);
									</script>
									<?php
								}
							}			
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                        	<h5>Nom</h5>
							<input autofocus type="text" class="form-control" name="nom" value="<?php if (isset($_POST['valider'])){echo $_POST['nom'];} ?>">
                        	<h5>Prénoms</h5>
							<input autofocus type="text" class="form-control" name="prenom" value="<?php if (isset($_POST['valider'])){echo $_POST['prenom'];} ?>">
                        	<h5>Login</h5>
							<input autofocus type="text" class="form-control" name="login" value="<?php if (isset($_POST['valider'])){echo $_POST['login'];} ?>">
                        	<h5>Email</h5>
							<input autofocus type="text" class="form-control" name="mail" value="<?php if (isset($_POST['valider'])){echo $_POST['mail'];} ?>">
                        	<h5>Téléphone</h5>
							<input autofocus type="text" class="form-control" name="tel" value="<?php if (isset($_POST['valider'])){echo $_POST['tel'];} ?>">
                        	<h5>Adresse</h5>
							<input autofocus type="text" class="form-control" name="adresse" value="<?php if (isset($_POST['valider'])){echo $_POST['adresse'];} ?>">
                        	<h5>Etat <span id="span">[0:Vérouiller ; 1:Déverouiller]</span></h5>
							<input autofocus type="text" class="form-control" name="etat" value="<?php if (isset($_POST['valider'])){echo $_POST['etat'];} ?>">
                            <h5>Agence</h5>
                            <select name="agence" class="form-control">
								<?php
                                $sql2 = "SELECT * FROM agences ORDER BY lib_agences ASC";
                                $reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
                                while ($data2 =$reponse2->fetch())
                                {
                                    if(isset($_POST['valider']) and $_POST['champ']==$data2[0])
                                    {
                                        echo $cocher=' selected="selected"';
                                    }
                                    else
                                    {
                                        echo $cocher='';
                                    }
                                    echo '<option'.$cocher.' value="'.$data2[0].'">'.$data2['lib_agences'].'</option>';
                                }
                                ?>
                            </select>
                            Mot de Passe *
                            <input placeholder="" class="form-control" type="password" name="mdp1">
                            Confirmer le Mot de Passe *
                            <input placeholder="" class="form-control" type="password" name="mdp2">
							<div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="gestionnaire-info.php?W9mvyDvFWE5=<?php echo $chaiz ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
						
						case 'membre':
						$id=addslashes($_GET['id']);
						$sql = 'SELECT * FROM membre WHERE id_membre='.$id;
						$reponse=$bdd-> query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
						$data =$reponse->fetch();
						$login_parrain=$data['pseudo_membre'];
						$membre_5=$data['5_membre'];
						$sql2= 'SELECT COUNT(*) FROM membre WHERE id_parain='.$id;
						$reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
						$data2=$reponse2->fetch();
						$nbr_filleul=$data2[0];
						if($nbr_filleul>=5)
						{
							header ('Location: inscriptionby.php');
						}
						?>
                        <div id="titro_parain">Parrain de <span><?php echo stripslashes($data['nom_membre']. ' '.$data['prenom_membre'].' ('.$data['pseudo_membre'].')') ?></span></div>
                        <div align="center">
							<?php
							if (isset($_POST['valider']))
							{
								$pseudo=addslashes(($_POST['pseudo']));
								$nom=addslashes(($_POST['nom']));
								$prenom=addslashes(($_POST['prenom']));
								$sexe=addslashes(($_POST['sexe']));
								$pays=addslashes(($_POST['pays']));
								$ville=addslashes(($_POST['ville']));
								$tel=addslashes(($_POST['tel']));
								$mail=addslashes(($_POST['mail']));
								$date_mise=date('Y-m-d H:i:s');
								
								$sql = 'SELECT count(*) FROM membre WHERE pseudo_membre="'.$pseudo.'"';
								$reponse=$bdd-> query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
								$data =$reponse->fetch();
								$nbr_pseudo=$data[0];
								
								$mdp=generer_mot_de_passe($nb_caractere=8);
								
								if (empty($pseudo))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le pseudo</div>';
								}
								elseif (empty($nom))
								{
									echo '<div class="alert alert-danger">Veuillez choisir le nom</div>';
								}
								elseif (empty($prenom))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le prénom</div>';
								}
								elseif (empty($sexe))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le sexe</div>';
								}
								elseif (empty($pays))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le pays</div>';
								}
								elseif (empty($tel))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le numéro de téléphone</div>';
								}
								elseif (empty($mail))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner le mail</div>';
								}
								elseif (empty($ville))
								{
									echo '<div class="alert alert-danger">Veuillez renseigner la ville</div>';
								}
								if ($nbr_pseudo>0)
								{
									echo '<div class="alert alert-danger">Ce pseudo existe déjà</div>';
								}
								elseif (!filter_var($mail, FILTER_VALIDATE_EMAIL))
								{
									echo '
									<div class="alert alert-danger">
										<strong>Erreur!</strong> Votre E-mail n\'est pas valide
									</div>';
								}
								else
								{
									$req='INSERT INTO '.$chaiz.' VALUES (NULL, "'.$pseudo.'", "", "'.$nom.'", "'.$prenom.'", "", NULL, "'.$sexe.'", "'.$mail.'", "'.$tel.'", "'.$ville.'", "", "'.md5($mdp).'", 1, 0, NULL, "'.$date_mise.'", NULL, NULL, "0", '.$pays.', '.$_SESSION['celest'].', '.$id.', "agent", "15000", "0", '.$_SESSION['celest'].', '.$_SESSION['celest'].', "'.$date_mise.'", "'.$date_mise.'", "'.$mdp.'", NULL, 0)';
									$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
									
									
									//générer le matricule du membre
									$sql2= 'SELECT MAX(id_'.$chaiz.') FROM '.$chaiz.'';
									$reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
									$data2=$reponse2->fetch();
									$id_membre=$data2[0];
									
									$zero=str_repeat(0,7-strlen($data2[0]));
									$matricule='MAT'.$zero.$data2[0];
									//mise à jour du matricule
									$req='UPDATE '.$chaiz.' SET matricule_'.$chaiz.'="'.$matricule.'", cool_'.$chaiz.'="1" WHERE id_'.$chaiz.'='.$data2[0].'';
									$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
									
									//incrémentation du nombre de filleul du parrain
									$req='UPDATE '.$chaiz.' SET 5_'.$chaiz.'="'.($membre_5+1).'" WHERE id_'.$chaiz.'='.$id.'';
									$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
									
									$sql2='SELECT COUNT(*) FROM membre WHERE id_parain='.$data2[0];
									$reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
									$data2=$reponse2->fetch();
									if($data2[0]>=5)
									{
										$req='UPDATE '.$chaiz.' SET date_filleul="'.$date_mise.'" WHERE id_'.$chaiz.'='.$id_membre.'';
										$reponse=$bdd-> query($req) or die('Erreur SQL !<br />'.$req.'<br />'.mysql_error());
									}
									echo '<div class="alert alert-success">Ajout effectué avec succès</div>';
									?> 
									<script type="text/javascript">
									window.setTimeout("location=('inscriptionby.php');",2500);
									</script>
									<?php
								}
							}
							?>
						</div>
						<form role="form" method="post" action="" enctype="multipart/form-data" name="form2">
                            Pseudo *
                            <input placeholder="" class="form-control" type="text" name="pseudo" value="<?php if (isset($_POST['valider']) ){echo $_POST['pseudo'];} ?>" required>
                            Nom *
                            <input placeholder="" class="form-control" type="text" name="nom" value="<?php if (isset($_POST['valider']) ){echo $_POST['nom'];} ?>" required>
                            Prénoms *
                            <input placeholder="" class="form-control" type="text" name="prenom" value="<?php if (isset($_POST['valider']) ){echo $_POST['prenom'];} ?>" required>
                            Sexe *
                            <select name="sexe" class="form-control">
                                <option value="">--------------</option>
                                <option value="M">Homme</option>
                                <option value="F">Femme</option>
                            </select>
                            Pays *
                            <select name="pays" class="form-control">
                                <?php
                                $sql2 = "SELECT * FROM pays ORDER BY nom_fr_fr ASC";
                                $reponse2=$bdd-> query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
                                while ($data2 =$reponse2->fetch())
                                {
                                    if($data2[0]==110)
                                    {
                                        echo $cocher=' selected="selected"';
                                    }
                                    else
                                    {
                                        echo $cocher='';
                                    }
                                    echo '<option'.$cocher.' value="'.$data2[0].'">'.$data2['nom_fr_fr'].'</option>';
                                }
                                ?>
                            </select>
                            Ville *
                            <input placeholder="" class="form-control" type="text" name="ville" value="<?php if (isset($_POST['valider']) ){echo $_POST['ville'];} ?>">
                            Téléphone * <span id="obligatoire">Ecrivez sans l'indice de votre pays Exemple: 08972260</span>
                            <input placeholder="08972260" class="form-control" type="text" name="tel" value="<?php if (isset($_POST['valider']) ){echo $_POST['tel'];} ?>" required>
                            Email *
                            <input placeholder="" class="form-control" type="text" name="mail" value="<?php if (isset($_POST['valider']) ){echo $_POST['mail'];} ?>" required>
                            Pseudo Parrain *
                            <input placeholder="" class="form-control" type="text" name="parrain" value="<?php echo $login_parrain; ?>" disabled>
                            <div id="valider">
								<input type="submit" class="btn btn-primary" value="Valider" name="valider">
								&nbsp; <a href="gestionnaire-info.php?W9mvyDvFWE5=<?php echo $chaiz ?>"><i class="fa fa-reply"></i> Retour</a>
							</div>
						</form>
						<?php
						break;
						
						default: header('administration.php');
					}
					?>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<?php 
}
else
{
	header('Location: index.php');
}
?>