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
| <?php require_once('../Connections/dream.php'); ?>
<?php
//init des variables
if(!isset($_POST['reference'])) $reference=""; else $reference=$_POST['reference'];
if(!isset($_POST['titre'])) $titre=""; else $titre=$_POST['titre'];
if(!isset($_POST['description'])) $description=""; else $description=$_POST['description'];
if(!isset($_POST['prix'])) $prix=""; else $prix=$_POST['prix'];
if(!isset($_POST['ref_menu'])) $ref_menu=""; else $ref_menu=$_POST['ref_menu'];
if(!isset($_POST['modifArticle'])) $modifArticle="non"; else $modifArticle=$_POST['modifArticle'];
if(!isset($_FILES['photo'])) $photo['photo']=array('name'=>'','size'=>0); else $photo['photo']=$_FILES['photo'];
//----------------------------
?>
<?php
$colname_rsRecupArticle = "-1";
if (isset($_GET['reference'])) {
$colname_rsRecupArticle = (get_magic_quotes_gpc()) ? $_GET['reference'] : addslashes($_GET['reference']);
}
mysql_select_db($database_dream, $dream);
$query_rsRecupArticle = sprintf("SELECT * FROM articles WHERE reference = '%s'", $colname_rsRecupArticle);
$rsRecupArticle = mysql_query($query_rsRecupArticle, $dream) or die(mysql_error());
$row_rsRecupArticle = mysql_fetch_assoc($rsRecupArticle);
$totalRows_rsRecupArticle = mysql_num_rows($rsRecupArticle);
mysql_select_db($database_dream, $dream);
$query_rsSelectTheme = "SELECT * FROM menu WHERE menu.id_menu_dir is not null ORDER BY id_menu ASC";
$rsSelectTheme = mysql_query($query_rsSelectTheme, $dream) or die(mysql_error());
$row_rsSelectTheme = mysql_fetch_assoc($rsSelectTheme);
$totalRows_rsSelectTheme = mysql_num_rows($rsSelectTheme);
mysql_select_db($database_dream, $dream);
$query_liste = "SELECT m1.id_menu, m2.id_menu_dir, m1.item_menu as 'menu parent', m2.item_menu as 'menu enfant' FROM menu m1, menu m2 WHERE m1.id_menu=m2.id_menu_dir ORDER BY m2.id_menu ";
$liste = mysql_query($query_liste, $dream) or die(mysql_error());
$row_liste = mysql_fetch_assoc($liste);
$totalRows_liste = mysql_num_rows($liste);
?>
<?php
if ($modifArticle=="ok")
{
//---Mise à jour dans la base
mysql_select_db($database_dream, $dream);
$updateArticles = "UPDATE articles SET titre='$titre', description='$description', prix='$prix', ref_menu='$ref_menu' ";
if ($photo['photo']['size']!=0)
{$photo_name=$_FILES['photo']['name'];
$updateArticles .= ", photo='$photo_name'";}
$updateArticles .= " WHERE reference='$reference' ";
mysql_query($updateArticles, $dream) or die(mysql_error());
//----Gestion de la photo de l'article si elle a était modifiée
if ($photo['photo']['size']!=0 )
{
$repertoire="../photos/";
move_uploaded_file($photo['photo']['tmp_name'],$repertoire.$photo['photo']['name']);
}
//----Redirection vers l'écran du message modif réussi
header("Location: valider.php");
}
?> |
Partager