1 2 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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| <!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">
<link rel="stylesheet" media="screen" type="text/css" title="fichier" href="fichier.css" />
<head>
<title>Comptes utilisateur</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<!-- L'en-tête -->
<div id="en_tete_2">
<p><h2>ADMINISTRATION DE COMPTE</h2></p>
</div><hr />
<?php
session_start();
if($_SESSION['login']==0)
{
echo '<p><span class="blink">Vous n\'êtes pas autorisé´ à acceder à cette page</span></p>';
exit;
}
if (isset($_POST['login']) AND isset($_POST['mot_de_passe']) AND isset($_POST['struture'])
AND isset($_POST['priority'])) // Si les variables existent
{
if($_POST['login']!= NULL AND $_POST['mot_de_passe']!= NULL AND $_POST['struture']!= NULL AND $_POST['priority']!= NULL )// si on a qlqe choz à entrer
{
mysql_connect("localhost", "root", "rat");//se connecter à la base de donnée
mysql_select_db("application"); //selection de la BD
// on utilise les fonctions PHP mysql_real_escape_string et htmlspecialchars pour la sécurité
$login= mysql_real_escape_string(htmlspecialchars($_POST['login']));
$mot_de_passe= mysql_real_escape_string(htmlspecialchars($_POST['mot_de_passe']));
$struture= mysql_real_escape_string(htmlspecialchars($_POST['structure']));
$priority= mysql_real_escape_string(htmlspecialchars($_POST['$priority']));
//ensuite on enregistre les infos
mysql_query("INSERT INTO utisateur VALUES('', '$login', '$mot_de_passe', '$struture', '$priority)'");
mysql_close();//deconnexion de mysql
}
}
//Que l'on ait enregistré ou pas des données
//On affiche les formulaires
?>
<!-- Le corps -->
<div id="corps">
<form method="post" action="user.php">
Veuillez remplir ces champs pour declarer ou modifier un compte d'utilisateur.<br />
<table >
<tr><td>Login:</td><td><input type="text" name="login" /></td></tr>
<tr>
<td>Mot de passe:</td><td><input type="password" name="mot_de_passe" /></td></tr>
<tr><td>Structure:</td><td><input type="text" name="structure" /></td></tr>
<tr>
<td>Privilège:</td><td><select name="priority">
<option value=""></option>
<option value="1">administrateur</option>
<option value="0">utilisateur</option>
</select></td><td><input type="submit" value="Envoyer" /></td></tr>
</table >
</form>
</div>
<?php
//maintenant on affiche les 5 dernières entrées de la table
mysql_connect ("localhost", "root", "rat");
mysql_select_db("application");
//on utilise la requête suitvante pour recuperer les derniers entrées de la table
$reponse = mysql_query("SELECT Login, structure, priority FROM utilisateur ORDER BY ID DESC LIMIT 0,5");
?>
<div id="voir">
<?php
echo'<table border="1"><tr>';
for ($i = 0; $i < mysql_num_fields($reponse); $i++) {
echo '<th>';
echo mysql_field_name($reponse, $i);
echo '</th>';}
echo '</tr>';
while ($row = mysql_fetch_row($reponse)) {
echo '<tr>';
for ($j = 0; $j < count($row); $j++) {
echo '<td>';
echo ($row[$j] == NULL) ? '<i>NULL</i>' : $row[$j];
echo '</td>';
}
echo '</tr>';
}
// On se déconnecte de MySQL
mysql_close();
?>
</body>
</html>. |
Partager