Bonjour, suite à édition d'une application, je ne suis plus en mesure de mettre à jours ma Base de donnée pour les module concernant les produits, en effet lorsque j' effectue une modification dans ma base de données via un formulaire, celle ci n'est pas prise en compte dans la base de donnée, après quelques heures de recherche et de réflexion, je n' arrive toujours pas à résoudre ce problème donc je viens demander un peu d' aide auprès de personne plus expérimenté.
Donc pour commencer voiçi INDEX
La Page HTML du formaulaire pour Edition de mon PRODUIT
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 case 'UpdateProduct': { if (isset($_POST)&&!empty($_POST)) { $Product_ID = $_POST['Product_ID']; $Name = $_POST['Name']; $Reference = $_POST['Reference']; $Code = $_POST['Code']; $Provider = $_POST['Provider']; $Description_Short = $_POST['Description_Short']; $Description = $_POST['Description']; $Category = $_POST['Category']; $Price = $_POST['Price']; $Quantity = $_POST['Product_Quantity']; $TVA = $_POST['ProductTVA']; // $Picture = $_POST['Product_Picture']; $Controller = new Products_Controller(); $Controller->C_Update_Product($Name, $Reference, $Code, $Provider, $Quantity, $Description, $Description_Short, $Category, $Price, $TVA); } } break;
Le Controleur de mon UPDATE du Produit
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
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 <?php include_once("View/Admin/Header_View.php");?> <!-- --> <div class=""> <span class="Product_Create_Choise"><a href="#Reference">Reference</a></span> <span class="Product_Create_Choise" ><a href="#Price">Price</a></span> <span class="Product_Create_Choise"><a href="#Picture">Picture</a></span> </div> <div class="Form_container"> <form class="Form_Create" method="POST" name="" action="index.php?Controller=Products&action=UpdateProduct"> <button type="submit" name"submit" value="envoyer">Update</button> <button type="submit" name"submit Cancel" value="Back" onClick="history.go(-1);return true;">Cancel</button> <div class="Block_Information" id="Reference"> <h3>Information</h3> <label for="Product_ID">Product ID:</label></br> <input type="text" DISABLED name="" value="ID <?php echo $Product_Edit['ProductID']; ?>"></br> <label for="Product_ID"></label> <input type="hidden" name="Product_ID" value="<?php echo $Product_Edit['ProductID']; ?>"></br> <label for="Name">Name:</label></br> <input type="text" placeholder="Name" name="Name" value="<?php echo $Product_Edit['ProductLib']; ?>"/></br> <h3>Reference</h3> <label for="Reference">Reference:</label></br> <input type="text" placeholder="Reference" name="Reference" value="<?php echo $Product_Edit['ProductReference']; ?>"/></br> <label for="Code">bar code:</label></br> <input type="text" placeholder="Code" name="Code" value="<?php echo $Product_Edit['ProductCode']; ?>"/></br> <label for="Provider">Provider:</label></br> <input type="text" placeholder="Provider" name="Provider" value="<?php echo $Product_Edit['ProductProvider']; ?>"/></br> <h3>Category Product</h3> <label for="Category">Category:</label></br> <select class="Category" name="Category"></br> <?php $selected = $Product_Cat['Category_ID']; foreach ($Product_Name_Select as $Category_selest):; ?> <option value="<?php echo $Category_selest["Category_ID"]; ?>" <?php if ($selected == $Category_selest["Category_ID"]){ echo('selected="selected"');} ?>> <?php echo $Category_selest["Category_Designation"]; ?> </option> <?php endforeach; ?> </select></br> <div class="form Form_Bot"> <label for="Description_Short">LONG DESCRIPTION</label></br> <textarea name="Description_Short" rows="8" cols="40"><?php echo $Product_Edit['ProductDescription']; ?></textarea></br> <label for="Description">SHORT DESCRIPTION</label></br> <textarea name="Description" rows="8" cols="40"><?php echo $Product_Edit['ProductDescriptionShort']; ?></textarea></br> </div> </div> <!-- //////////////////////////////////////////////////////////////////////////////////////////////// --> <div class="Block_Price" id="Price"> <h3>PRICE & STOCK</h3> <label for="Price">Price:</label></br> <input type="number" placeholder="Price" name="Price" step="0.01" min="0.01" max="99" value="<?php echo $Product_Edit['ProductPrice']; ?>"/></br> <label for="Product_Quantity">Product Quantity</label></br> <input type="number" placeholder="Product Quantity" name="Product_Quantity" value="<?php echo $Product_Edit['ProductQuantity']; ?>" /></br> <label for="TVA">TVA:</label></br> <select class="" name="ProductTVA"> <?php $selected = $Product_TVA['ProductTVAID']; foreach ($TVA as $TVA_selest):; ?> <option value="<?php echo $TVA_selest['ProductTVAID']; ?>" <?php if ($selected == $TVA_selest['ProductTVAID']){ echo('selected="selected"');} ?>> <?php echo $TVA_selest['ProductTVADescription']; ?> <?php echo " : ".$TVA_selest['ProductTVA']." %"; ?> </option> <?php endforeach; ?> </select></br> </div> <div class="Block_Picture" id="Picture"> <h3>Picture</h3> <label for="Picture">Picture:</label></br> <input type="file" placeholder="Picture" name="Picture" value="" /></br> </div> </form> </form> </div>
et mon MODEL de Update du mon Produit
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 function C_Update_Product($Name, $Reference, $Code, $Provider, $Quantity, $Description, $Description_Short, $Category, $Price, $TVA) { $Model = New Products_Model; $Product_Update = $Model->M_Update_Product($Name, $Reference, $Code, $Provider, $Quantity, $Description, $Description_Short, $Category, $Price, $TVA); if ($Product_Update==true) { $_SESSION['Valid'] = "Product $Name Update Congraduation."; header ('Location: Index.php?Controller=Products&action=D_Products'); } else { $_SESSION['Error'] = "Error : Edit product does not Update."; header ('Location: Index.php?Controller=Products&action=EditProduct'); } }
Et pour Finir la Base de donnée qui va avec.
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 function M_Update_Product($Name, $Reference, $Code, $Provider, $Quantity, $Description, $Description_Short, $Category, $Price, $TVA) { try { $req= BDD::getConnect()->prepare(" UPDATE `_products` SET `ProductLib`=:Name, `ProductQuantity`=:Quantity, `ProductDescription`=:Description, `ProductDescriptionShort`=:DescriptionShort, `ProductPrice`=:Price,`ProductReference`=:Reference, `ProductCode`=:Code, `ProductProvider`=:Provider, `ProductTVAID`=:TVA, `Category_ID`=:Category WHERE `ProductID`=:ID "); // , `ProductPicture`=':Picture ' $req->bindParam(':Name',$Name); $req->bindParam(':Quantity',$Quantity); $req->bindParam(':Description',$Description); $req->bindParam(':DescriptionShort',$Description_Short); $req->bindParam(':Price',$Price); $req->bindParam(':Reference',$Reference); $req->bindParam(':Code',$Code); $req->bindParam(':Provider',$Provider); $req->bindParam(':TVA',$TVA); $req->bindParam(':Category',$Category); // $req->bindParam(':Picture',$Picture); $req->bindParam(':ID',$Product_ID); if( $req->execute() ) { return true; } return false; } catch (Exception $e) { die($e->getMessage()); } }
Je suppose que j' ai dû faire une faute de syntaxe ou autre mais impossible après plusieurs heures de comprendre mon réelle problème.
Donc si quelque à une idée, je suis preneur et désespère xD.
Coordialement Guillaume
Partager