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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
<? require_once('classconnexion.php') ?>
<?php
session_start(); // On relaye la session
if (session_is_registered("authentification") && $_SESSION['privilege'] == "admin")
{
}
else {
header("Location:authentification.php?erreur=intru"); // redirection en cas d'echec
}
?>
<?php
// ------ AJOUT D'UN PROGRAMME --------
if(isset($_POST['dated'])){
if(($_POST['dated'] == "")|| ($_POST['datef'] == "")|| ($_POST['lieu'] == "")|| ($_POST['hotel'] == "")){
header("Location:prog.php?erreur=empty");
}
else {
$dated = $_POST['dated'];
$df = $_POST['datef'];
$lieu = $_POST['lieu'];
$hotel = $_POST['hotel'];
// on fait l'INSERT dans la base de données
$add_user = sprintf("INSERT INTO programme (dated,datef,lieu,hotel) VALUES ('$dated,$df,$lieu,$hotel')");
$dbprotect = mysql_pconnect("localhost","root", "") or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db('conférence1', $dbprotect);
$result = mysql_query($add_user,$dbprotect) or die(mysql_error());
header("Location:prog.php?add=ok");
}
}
// ------ SUPPRESSION D'UN PROGRAMME --------
$dbprotect = mysql_pconnect("localhost","root", "") or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db('conférence1', $dbprotect);
$query_users = "SELECT * FROM programme ";
$users = mysql_query($query_users,$dbprotect) or die(mysql_error());
$row_users = mysql_fetch_assoc($users);
if(isset($_POST['suppr']) && ($_POST['suppr'] != "1")){
$id = $_POST['suppr'];
$delete_user = sprintf("DELETE FROM programme WHERE id='$id'");
$dbprotect = mysql_pconnect("localhost","root", "") or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db('conférence1', $dbprotect);
$result = mysql_query($delete_user,$dbprotect) or die(mysql_error());
header("Location:prog.php?delete=ok");
}
?>
<html>
<head>
<title>ADMINISTRATION </title>
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<form action="" method="post" name="add">
<div class="titre">- : : : ESPACE ADMINISTRATION : : : -</div>
<p align="center">
<?php if(isset($_GET['add']) && ($_GET['add'] == "ok")) { // Affiche l'erreur ?>
<span class="reussite">Le programme a été créé avec succès !</span>
<?php } ?>
<?php if(isset($_GET['erreur']) && ($_GET['erreur'] == "empty")) { // Affiche l'erreur ?>
<span class="erreur">Un petit oubli non ? Veuillez renseigner tous les champs SVP</span>
<?php } ?>
</p>
<p align="center"><strong><u>Créer un programme</u></strong></p>
<table width="350" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#eeeeee" class="tableaux">
<tr>
<td width="40">Date début</td>
<td width="144"><input name="dated" type="text" id="dated"></td>
</tr>
<tr>
<td width="40">Date fin</td>
<td width="144"><input name="datef" type="text" id="datef"></td>
</tr>
<tr>
<td width="40">Lieu</td>
<td width="144"><input name="lieu" type="text" id="lieu"></td>
</tr>
<tr>
<td width="40">Hotel</td>
<td width="144"><input name="hotel" type="text" id="hotel"></td>
</tr>
<tr>
<td height="50" colspan="2"><div align="center">
<input type="submit" name="Submit" value="Créer ce programme">
</div></td>
</tr>
</table>
</form>
<p align="center"><strong>
<?php
if(isset($_GET['delete']) && ($_GET['delete'] == "ok")) { // Affiche l'erreur ?>
<span class="reussite">La famille a été supprimé avec succès</span>
<?php } ?>
<?php
if(isset($_POST['verif']) && (!isset($_POST['suppr']))) { // Affiche l'erreur ?>
</strong><span class="erreur">Veuillez sélectionner le programme à supprimer </span>
<?php } ?>
<form action="" method="post" name="suppr">
<p align="center"><strong><u>Supprimer un programme</u></strong></p>
<div align="center"><table width="500" border="0" cellpadding="5" cellspacing="0" class="tableaux">
<tr>
<td width="240"><div align="center">
<select name="suppr" size="5" id="select1">
<?php
do {
?>
<option value="<?php echo $row_users['id']?>">
<?php echo $row_users['dated']." ". $row_users['lieu']." (".$row_users['hotel'].")";; ?>
</option>
<?php
} while ($row_users = mysql_fetch_assoc($users));
$rows = mysql_num_rows($users);
if($rows > 0) {
mysql_data_seek($users, 0);
$row_users = mysql_fetch_assoc($users);
}
?>
</select>
<input name="verif" type="hidden" id="verif">
</div></td>
<td width="157"><input type="submit" name="Submit2" value="Supprimer ce programme"></td>
</tr>
</table>
<p><a href="acceuil.php"><strong>< Retour accueil</strong></a></p>
</div>
</form>
</body>
</html> |
Partager