Bonjour,
j'ai réalisé un script pour modifier les données d'une table, pour mon espace administration.
j'ai 2 tables , menu et articles.Je veux pouvoir modifier la table articles.
je n'ai aucune erreur mais malheureusement après avoir envoyé le formulaire rien ne se passe, aucune modification n'est effectuée. je vous donne le code si vous pouvez m'aider çà serait formidable.
le formulaire:
le script php:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <form action="modifierarticles.php" method="post" enctype="multipart/form-data" name="form1"> <table width="700" height="314" border="1" cellpadding="0" cellspacing="0" bordercolor="#CC9933"> <tr> <td><div align="center"> <table width="659" border="0" cellspacing="0" cellpadding="5"> <tr> <td width="146"><div align="right"></div></td> <td width="271"><div align="left"> </div></td> <td width="212" rowspan="7"><div align="center"> <p><img src="../photos/<?php echo $row_rsRecupArticle['photo']; ?>" alt="" name="photo" width="160" height="135"></p> <p><?php echo $row_rsRecupArticle['photo']; ?></p> </div></td> </tr> <tr> <td><div align="right">Titre : </div></td> <td><div align="left"> <input name="titre" type="text" id="titre" value="<?php echo $row_rsRecupArticle['titre']; ?>"> </div></td> </tr> <tr> <td><div align="right"></div></td> <td><div align="left"> </div></td> </tr> <tr> <td><div align="right">Description : </div></td> <td><div align="left"> <textarea name="description" cols="40" id="description"><?php echo $row_rsRecupArticle['description']; ?></textarea> </div></td> </tr> <tr> <td><div align="right">Prix : </div></td> <td><div align="left"> <input name="prix" type="text" id="prix" value="<?php echo $row_rsRecupArticle['prix']; ?>" size="10"> </div></td> </tr> <tr> <td><div align="right">Sous menu : </div></td> <td><div align="left"> <select name="ref_menu" id="ref_menu" title=""> <?php do { ?> <option value="<?php echo $row_rsSelectTheme['id_menu']?>"<?php if (!(strcmp($row_rsSelectTheme['id_menu'], $row_rsRecupArticle['ref_menu']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsSelectTheme['item_menu']?></option> <?php } while ($row_rsSelectTheme = mysql_fetch_assoc($rsSelectTheme)); $rows = mysql_num_rows($rsSelectTheme); if($rows > 0) { mysql_data_seek($rsSelectTheme, 0); $row_rsSelectTheme = mysql_fetch_assoc($rsSelectTheme); } ?> </select> </div></td> </tr> <tr> <td><div align="right">Image : </div></td> <td><div align="left"> <input type="hidden" name="MAX_FILE_SIZE" value="100000"> <input name="photo" type="file" id="photo"> </div></td> </tr> <tr> <td colspan="3"><div align="right"></div> <div align="center"> <input type="submit" name="Submit" value="MODIFIER"> <input name="modifArticle" type="hidden" id="modifArticle" value="ok"> </div></td> </tr> </table> </div></td> </tr> </table> </form>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?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 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); ?> <?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