<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8"/>
		<title>Gestion des Médias</title>
		<link rel="shortcut icon" type="image/x-icon" href="../mmd/favicon.ico"/>
		<link rel="stylesheet" type="text/css" href="../style.css"/>
		<link rel="stylesheet" type="text/css" href="style.css"/>
		<script type="text/javascript" src="jquery.js"></script>
	</head>
	<body>
		<h1>Gestion des Médias</h1>
		<a href="../"><div class="back_arrow"></div></a>
		<form action="upload.php" method="post" enctype="multipart/form-data" style="margin-top:15%;">
			<p style="color:white;">Selectionnez le point correspondant au média: </p>
			<label class="select">
			<select name="point">
			<?php
				// connexion à la base
				$db = mysql_connect('localhost', 'root', 'm148r43a9Y@%Z') or die('Erreur de connexion '.mysql_error());

				// sélection de la base  
				mysql_select_db('smartpassTest2',$db) or die('Erreur de selection '.mysql_error());

				// envoie de la requète
				$select = mysql_query("select id, NomDeLetablissement from InformationsGenerales");

				while($fetch = mysql_fetch_array($select)){
					echo '<option value='.$fetch['id'].'>';
					echo $fetch['NomDeLetablissement'];
					echo '</option>'; 
				}
			?>
			</select>
			<i></i>
			</label>
			<input class="inputfile" id="file" name="file" type="file" style="display:none;">
			<label class="selectfile" for="file">Selectionnez votre image...</label>
			<p class="returnfile"></p>

			<input type="submit" value="Envoyer" name="submit" class="myButton">

		</form>

		<script type="text/javascript">
			$(document).ready(function() {

				//on déclare nos variables
				var inputFile = document.querySelector( ".inputfile" ),
					selectFile = document.querySelector( ".selectfile" ),
					returnFile = document.querySelector(".returnfile");
				
				//lorsque l'on clique sur le boutton
				selectFile.addEventListener( "click", function( event ) {
					inputFile.focus();
					return false;
				});
				
				//lorqu'une image est séléctionnée
				inputFile.addEventListener( "change", function( event ) {
					selectFile.innerHTML = "Image Séléctionnée !";
					returnFile.innerHTML = this.value;
				});

			});
		</script>
	</body>
</html>