| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 
 | <?php
		session_start();
 
		mysql_connect("localhost", "root", ""); // Connexion à MySQL
		mysql_select_db("evian royal resort"); // Sélection de la base evian royal resort
 
?>
 
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
    <head>
        <title>Ajouter employé</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    <body>
 
		<p><center><h1>Ajout de personnel</h1></center></p> <hr>
		<p> <?php 
		// on récupère le numéro identifiant de l'utilisateur grâce à la variable session.
		$id = $_SESSION['Id_CDS'];
		// Grâce à l'identifiant on récupère le service de l'utilisateur pour qu'il ne puisse insérer qu'au sein de son service
		$sql ="SELECT Service FROM `chef_de_service` WHERE Id_CDS='$id'";
		$query = mysql_query($sql) or die($sql . ' : '  . mysql_error());
		$data=  mysql_fetch_assoc($query);
		$service=$data['Service'];	
		?>
 
		<form action="" method="post">
	<p>
<li>Nom employé 		: <input type="text" name="nom" /> </br>
<li>Prénom employé  	: <input type="text" name="prenom" />  </br> 
<li>Emploi      		: <input type="text" name="emploi" />  </br>
<li>Section     		: <input type="text" name="service" value="<?php echo $service; ?>"READONLY>  </br>
<li>Salaire     		: <input type="float" name="salaire" />  </br></br>
<input type="submit" value="Inserer" />
	</p>
       </form>
   </body>
</html>
 
		<?php
if (isset($_POST['nom']) && isset($_POST['prenom']) && isset($_POST['emploi']) && isset($_POST['section']) && isset($_POST['salaire']))
		{
		// On utilise la fonction PHP htmlentities pour éviter d'enregistrer du code HTML dans la table
		$nom = htmlentities ($_POST['nom'],ENT_QUOTES);
		$prenom = htmlentities ($_POST['prenom'],ENT_QUOTES);
		$emploi = htmlentities ($_POST['emploi'],ENT_QUOTES);
		$section = htmlentities ($_POST['service'],ENT_QUOTES);
		$salaire = htmlentities ($_POST['salaire'],ENT_QUOTES);
 
		$sql2 = "INSERT INTO personnel (Id_Perso, Nom_Perso, Prenom_Perso, Emploi, Id_Section, Salaire_Perso) VALUES('','$nom','$prenom','$emploi','$service','$salaire')";
		$query2 = mysql_query($sql2) or die('Erreur SQL !'.$sql2.''.mysql_error()); 
 
		echo 'L\'employé a bien été inseré';
		}
else	{
		echo 'Erreur : l\'employé n\'a pas été inséré';
		}
		mysql_close(); 
		?> | 
Partager