| 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
 63
 64
 65
 66
 67
 68
 69
 70
 71
 
 | <!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>ajout de personnel</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    <style type="text/css">
    form
    {
    text-align:left;
    }
    </style>
    <body>
 
 <? include("haut.php");
 ?>
 
 
<?php
if (isset($_POST['centre']) AND isset($_POST['matricule']) AND isset ($_POST['grade']) AND isset ($_POST['nom']) AND isset ($_POST['prenom'])) // Si les variables existent
{
 
if ($_POST['centre'] != NULL AND $_POST['matricule'] != NULL AND $_POST['grade'] != NULL AND $_POST['nom'] != NULL AND $_POST['prenom'] != NULL) // Si on a quelque chose à enregistrer
 
    {
        // D'abord, on se connecte à MySQL
        mysql_connect("localhost", "root", "");
        mysql_select_db("test");
 
        // On utilise les fonctions PHP mysql_real_escape_string et htmlspecialchars pour la sécurité
        $centre = mysql_real_escape_string(htmlspecialchars($_POST['centre']));
        $matricule = mysql_real_escape_string(htmlspecialchars($_POST['matricule']));
        $grade = mysql_real_escape_string(htmlspecialchars($_POST['grade']));
        $nom = mysql_real_escape_string(htmlspecialchars($_POST['nom']));
        $prenom = mysql_real_escape_string(htmlspecialchars($_POST['prenom']));
 
        // Ensuite on enregistre le message
        mysql_query("INSERT INTO personnel VALUES('', '$centre', '$matricule', '$grade', '$nom', '$prenom')");
 
        // On se déconnecte de MySQL
        mysql_close();
    }
}
 
 
 
// Tout d'abord le formulaire :
?>
 
 
 
<form action="ajout_personnel.php" method="post">
 
<p>
Centre : <input type="text" name="centre" /><br />
Matricule :  <input type="text" name="matricule" /><br />
Grade :  <input type="text" name="grade" /><br />
Nom :  <input type="text" name="nom" /><br />
Prénom :  <input type="text" name="prenom" /><br />
 
<input type="submit" value="Envoyer" />
</p>
 
</form>
 
 <? include("affichage_personnel.php");
 
 ?>
 
    </body>
</html> | 
Partager