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
| <!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" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
h3, form
{
text-align:center;
}
</style>
</head>
<body>
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("infos");
if (isset($_GET['modifier_infos']))
{
$_GET['modifier_infos'] = mysql_real_escape_string(htmlspecialchars($_GET['modifier_infos']));
$retour = mysql_query('SELECT * FROM infos WHERE id=\'' . $_GET['modifier_infos'] . '\'');
$donnees = mysql_fetch_array($retour);
// On place le titre et le contenu dans des variables simples
$titre = stripslashes($donnees['titre']);
$contenu = stripslashes($donnees['contenu']);
$photo=stripslashes($donnees['photo']);
$id_info = $donnees['id']; // Cette variable va servir pour se souvenir que c'est une modification
}
else // C'est qu'on rédige une nouvelle info
{
// Les variables $titre et $contenu sont vides, puisque c'est une nouvelle news
$titre = '';
$contenu = '';
$photo='';
$id_info = 0; // La variable vaut 0, donc on se souviendra que ce n'est pas une modification
}
?>
<form action="liste_infos.php" method="post">
<p>Titre : <input type="text" size="30" name="titre" value="<?php echo $titre; ?>" /></p>
<p>
Contenu :<br />
<textarea name="contenu" cols="50" rows="10">
<?php echo $contenu; ?>
</textarea><br />
<input type="file" name="photo" value="<?php echo $id_photo;?>"/>
<input type="hidden" name="id_info" value="<?php echo $id_info; ?>" />
<input type="submit" value="Envoyer" />
</p>
</form>
</body>
</html> |
Partager