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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
|
<?php
session_start();
if (!isset($_SESSION['login'])) {
header ('Location: index.php');
exit();
}
?>
<?php
include("includes/fonctions.php");
include("includes/bdd.php");
?>
<?php
if(isset($_POST['envoyer'])){
//On récupère les valeurs entrées par l'utilisateur :
$tb=$_POST['tb'];
$categorie=$_POST['categorie'];
$pseudo=$_POST['pseudo'];
$mail=$_POST['mail'];
$titre=$_POST['titre'];
$nbp=$_POST['nbp'];
$difficulte=$_POST['difficulte'];
$duree=$_POST['duree'];
$dureec=$_POST['dureec'];
$ingredients=$_POST['ingredients'];
$phasetechnique=$_POST['phasetechnique'];
$conseil=$_POST['conseil'];
}
//On se connecte
connectMaBase();
if (empty($pseudo)
|| empty($mail)
|| empty($categorie)
|| empty($titre)
|| empty($nbp)
|| empty($difficulte)
|| empty($duree)
|| empty($dureec)
|| empty($ingredients)
|| empty($phasetechnique)
|| empty($conseil))
{
$alert = 'faut rien oublier';
}
else {
//On prépare la commande sql d'insertion
$sql = 'INSERT INTO '.$tb.' VALUES("", "'.$titre.'", "'.$nbp.'", "'.$difficulte.'", "'.$duree.'", "'.$dureec.'", "'.$ingredients.'", "'.$phasetechnique.'", "'.$conseil.'", "'.$categorie.'", "'.$pseudo.'", "'.$mail.'")';
/*on lance la commande (mysql_query) et au cas où,
on rédige un petit message d'erreur si la requête ne passe pas (or die)
(Message qui intègrera les causes d'erreur sql)*/
mysql_query ($sql) or die ('Erreur SQL !'.$sql.'<br />'.mysql_error());
// on affiche le résultat pour le visiteur
$alert = 'La recette à été ajouter';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="fr">
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type">
<title>Mille et une recettes</title>
<link href="../pages/includes/style.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="990" height="330" background="../images/contenu-fond.jpg">
<tr>
<td width="1014" height="283" background="../images/header.jpg" colspan="5" align="center">
</td>
</tr>
<tr>
<td width="240" height="317" rowspan="2" align="center" valign="top">
<div align="left">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="230" height="156">
<tr>
<td width="100%" height="113" background="../images/menu-fond.jpg"><?php echo $menugauche; ?></td>
</tr>
<tr>
<td width="100%" height="33" background="../images/menu-bas.jpg"></td>
</tr>
</table>
</div>
</td>
<td width="11" height="317" rowspan="2"></td>
<td width="1" height="1"></td>
<td width="116" height="1" valign="top">
<img border="0" src="../images/titre.jpg" width="109" height="47" align="left"></td>
<td width="624" height="1" valign="middle">
<h2>Bienvenue dans la partie administration <?php echo htmlentities(trim($_SESSION['login'])); ?></h2></td></td>
</tr>
<tr>
<td width="771" height="270" colspan="3" align="center">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="83%" bgcolor="#FDCD6E">
<tr>
<td width="100%">
<?php
if (!empty($alert))
{
echo '<p style="color:red">'.$alert.'</p>';
}
?></td>
</tr>
</table>
</center>
</div>
<?php
connectMaBase(); //Connexion à la base de données
// La requête sql pour récupérer les messages de la page actuelle.
$retour_tb_user=mysql_query('SELECT * FROM user ORDER BY id ASC');
while($donnees_tb_user=mysql_fetch_assoc($retour_tb_user)) // On lit les entrées une à une grâce à une boucle
{
echo '<div align="center">
<center>
<form method="post" action="voir_recettes.php" name="">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="52%" height="131" bgcolor="#FDCD6E">
<tr>
<td width="107%" height="13" colspan="6">
<img border="0" src="../images/admin.gif" width="14" height="14"></td>
</tr>
<tr>
<td width="107%" height="6" colspan="6">
<img border="0" src="../images/admin.gif" width="14" height="14"></td>
</tr>
<tr>
<td width="12%" height="11">Pseudo</td>
<td width="24%" height="11"><input type="text" name="pseudo" size="22" value="'.$donnees_tb_user['pseudo'].' ? .$pseudo."></td>
<td width="5%" height="11">Mail</td>
<td width="22%" height="11"><input type="text" name="mail" size="20" value="'.$donnees_tb_user['mail'].' ? .$mail."></td>
<td width="8%" height="11">Catégorie</td>
<td width="36%" height="11"><input type="text" name="tb" size="17" value="'.$donnees_tb_user['tb'].' ? .$tb."></td>
</tr>
<tr>
<td width="12%" height="24">Titre</td>
<td width="23%" height="24"><input type="text" name="titre" size="22" value="'.$donnes_tb_user['titre'].' ? .$titre."></td>
<td width="4%" height="24">Nbp</td>
<td width="22%" height="24"><input type="text" name="nbp" size="20" value="'.$donnees_tb_user['nbp'].' ? .$nbp."></td>
<td width="9%" height="24">Difficulté</td>
<td width="37%" height="24">
<input type="text" name="difficulte" size="17" value="'.$donnees_tb_user['difficulte'].' ? .$difficulte."></td>
</tr>
<tr>
<td width="11%" height="18">Préparation</td>
<td width="45%" height="18" colspan="3">
<input type="text" name="duree" size="22" value="'.$donnees_tb_user['duree'].' ? .$duree."></td>
<td width="9%" height="18">Cuisson</td>
<td width="36%" height="18"><input type="text" name="dureec" size="17" value="'.$donnees_tb_user['dureec'].' ? .$dureec."></td>
</tr>
<tr>
<td width="11%" height="12">Ingrédients</td>
<td width="89%" height="12" colspan="5">
<textarea rows="5" name="ingredients" cols="58" value="'.$donnees_tb_user['ingredients'].' ? .$ingredients."></textarea></td>
</tr>
<tr>
<td width="11%" height="36">Phase technique</td>
<td width="89%" height="36" colspan="5">
<textarea rows="5" name="phasetechnique" cols="58" value="'.$donnees_tb_user['phasetechnique'].' ? .$phasetechnique."></textarea></td>
</tr>
<tr>
<td width="11%" height="13">Conseil</td>
<td width="89%" height="13" colspan="5">
<textarea rows="5" name="conseil" cols="58" value="'.$donnees_tb_user['conseil'].' ? .$conseil."></textarea></td>
</tr>
<tr>
<td width="11%" height="18"></td>
<td width="29%" height="18" colspan="2"></td>
<td width="30%" height="18" colspan="2">
<input type="submit" name="envoyer" value="Ajouter la recette">
</td>
<td width="36%" height="18"></td>
</tr>
<tr>
<td width="100%" height="11" colspan="6">
<img border="0" src="../images/admin.gif" width="14" height="14"></td>
</tr>
<tr>
<td width="100%" height="6" colspan="6">
<img border="0" src="../images/admin.gif" width="14" height="14"></td>
</tr>
<tr>
<td width="100%" height="8" colspan="6" bgcolor="#FFFFFF"></td>
</tr>
</table>
</form>
</center>
</div>';
}
?>
</td>
</tr>
<tr>
<td width="1022" height="29" align="center" valign="top" colspan="5" background="../images/contenu-bas.jpg">
</td>
</tr>
</table>
</div>
</body>
</html> |
Partager