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
| <?php
include('../fonctions/config.inc.php');
if($_POST['mod_tableau'] == '') {
header('Location: admin.php');
}
$id = $_POST['mod_tableau'];
$select = mysql_query('SELECT * FROM tableau WHERE id_tableau = '.$id);
$nom = mysql_result($select, 0, 'nom_tableau');
$prix = mysql_result($select, 0, 'prix_tableau');
$dim = mysql_result($select, 0, 'dim_tableau');
$cat = mysql_result($select, 0, 'cat_tableau');
if(isset($_POST['submit'])) {
$nom = mysql_real_escape_string(trim($_POST['nom_modif']));
$prix = mysql_real_escape_string(trim($_POST['prix_modif']));
$dim = mysql_real_escape_string(trim($_POST['dim_modif']));
$cat = mysql_real_escape_string(trim($_POST['cat_modif']));
$select_nom = mysql_query('SELECT * FROM tableau WHERE id_tableau = '.$id);
$ancien_nom = mysql_result($select_nom, 0, 'nom_tableau');
$ext = mysql_result($select_nom, 0, 'ext_tableau');
rename('../mini/'.$ancien_nom.'.'.$ext, '../mini/'.$nom.'.'.$ext);
rename('../maxi/'.$ancien_nom.'.'.$ext, '../maxi/'.$nom.'.'.$ext);
$modif = mysql_query('UPDATE tableau SET nom_tableau = '.$nom.',
prix_tableau = '.$prix.'
dim_tableau = '.$dim.'
cat_tableau = '.$cat.'
WHERE id_tableau = '.$id);
header('Location : admin.php');
}
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>
</title>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="general">
<fieldset>
<legend>Modification de "<?php echo $nom ?>"</legend>
<form action="admin.php" method="post">
<input name="id_modif" type="hidden" value="<?php echo $id; ?>" />
<table>
<tr><td><label>Nom</label> : </td><td><input name="nom_modif" type="text" value="<?php echo $nom; ?>" /></td></tr>
<tr><td><label>Prix</label> : </td><td><input name="prix_modif" type="text" value="<?php echo $prix; ?>" /></td></tr>
<tr><td><label>Dimensions</label> : </td><td><input name="dim_modif" type="text" value="<?php echo $dim; ?>" /></td></tr>
<tr><td><label>Catégorie</albel> : </td><td><select name="cat_modif">
<option value="0" <?php if($cat==0){echo 'selected';} ?>>Aquarelle</option>
<option value="1"<?php if($cat==1){echo 'selected';} ?>>Pastel</option>
<option value="2"<?php if($cat==2){echo 'selected';} ?>>Peinture</option>
<option value="3"<?php if($cat==3){echo 'selected';} ?>>Vendu</option>
</select></td></tr>
<tr><td><input name="submit" type="submit" value="Envoyer" /></td></tr>
</table>
</form>
</fieldset>
</div>
</body>
</html> |
Partager