Undefined index lors d'un update de la base
Bonjour,
je rencontre un pb lors de la modification d'une base qui de premier regard semble banal mais dont je ne trouve pas la réponse.
J'ai un document chargesoperationelles_modifier2.php qui affiche les données dans un formulaire pour modification. Et le document modifier3.php est sensé faire l'update. Là j'ai un message d'undex undefined . J'ai testé avec une variable - la surface. Si Dans l'update je donne la valeur exacte ex surface =80, la modification se fait. Si cela reste avec surface = ".$surface." j'ai le fameux message. J'ai testé les isset et les empty ...on dirait qu'il y a rien qui marche. Pourtant j'ai regardé pas mal de docs sur le web. Avez vous une idée?? Merci!
-----------------chargesoperationelles_modifier2.php---------------------------
Code:
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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
| <form method="POST" action="modifier3.php">
<!--action="chargesoperationnelles_modifier2.php?idculture=<?php echo $prevelevementRow[0];?>&idexploitation=<?php echo $idexploitation;?>-->
<input type="hidden" name="idculture" value="<?php echo($idculture) ;?>">
<table border="0" align="center" cellspacing="2" cellpadding="2" style="font-family: Arial;font-size: 10pt; color: #3D4970">
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>IDCULTURE </td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="IDCULTURE" value="<?php echo($prevelevementRow['idculture']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>CULTURE</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="CULTURE" value="<?php echo($prevelevementRow['culture']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>SURFACE</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="SURFACE" value="<?php echo($prevelevementRow['surface']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>RENDEMENT</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="RENDEMENT" value="<?php echo($row['rendement']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>PRIX VENTE</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="PRIXVENTE" value="<?php echo($row['prixvente']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>AUTRES PRODUITS</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="AUTRESPRODUITS" value="<?php echo($row['autresproduits']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>SEMENCES ACHETES</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="SEMENCES ACHETES" value="<?php echo($row['semencesachetes']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>SEMENCES PRELEVES</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="SEMENCESPRELEVES" value="<?php echo($row['semencespreleves']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>TOTAL SEMENCES</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="TOTALSEMENCES" value="<?php echo($row['semences']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>N</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="N" value="<?php echo($row['n']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>P</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="P" value="<?php echo($row['p']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>K</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="K" value="<?php echo($row['k']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>S</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="S" value="<?php echo($row['s']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>Mg</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="Mg" value="<?php echo($row['mg']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>FERTILISATION MINERALE</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="COUTFERTIMIN" value="<?php echo($row['fertimin']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>FERTILISATION ORGANIQUE</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="COUTFERTIORG" value="<?php echo($row['fertiorg']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>AMENDEMENT </td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="AMENDEMENT" value="<?php echo($row['amendement']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>DESHERBAGE</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="DESHERBAGE" value="<?php echo($row['desherbage']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial;font-size: 10pt; color: #B99867;">
<td>FONGICIDE</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="INSECTICIDE" value="<?php echo($row['fongicide']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>INSECTICIDE</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="INSECTICIDE" value="<?php echo($row['insecticide']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>LIMACE</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="LIMACE" value="<?php echo($row['limace']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>REGULATEUR</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="REGULATEUR" value="<?php echo($row['regulateur']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>DIVERS</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="DIVERS" value="<?php echo($row['divers']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>ASSURANCE GRELE</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="ASSURANCEGRELE" value="<?php echo($row['assurancegrele']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>ASSURANCE RECOLTE</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="ASSURANCERECOLTE" value="<?php echo($row['assurancerecolte']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>SECHAGE</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="SECHAGE" value="<?php echo($row['sechage']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>IRRIGATION</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="IRRIGATION" value="<?php echo($row['irrigation']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>INDEMNITE GRELE</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="INDEMNITEGRELE" value="<?php echo($row['indemnitegrele']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>AIDES PROTEAGINEUX</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="AIDESPROTEAGINEUX" value="<?php echo($row['aidesproteagineux']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>AIDES MAE</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="AIDESMAE" value="<?php echo($row['aidesmae']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>DPU</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="DPU" value="<?php echo($row['dpu']) ;?>"></td>
</tr>
<tr align="center" style="font-family: Arial bold;font-size: 10pt; color: #B99867;">
<td>TOTAL AIDES</td>
<td><input type="text" style="font-family: Arial;font-size: 9pt; color: #3D4970" name="TOTALAIDES" value="<?php echo($row['totalaides']) ;?>"></td>
</tr>
<tr align="center">
<td colspan="2">
<input type="hidden" name="millesime" value="<?php echo $annee ?>"></div>
<input type="hidden" name="idculture" value="<?php echo $idculture ?>"></div>
<input type="hidden" name="idexploitation" value="<?php echo $idexploitation; ?>"> <!-- champ cache -->
<input type="submit" class="submit" name="modifier" value="MODIFIER"></td>
</tr>
</tr>
</table>
</form> |
----------------------modifier3.php
Code:
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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
| <?php
$connectionPostgres = pg_connect("host=localhost port=5432 user=postgres password=postgres dbname=margebrute58_test");
//Appel au paramétrage du millésime
include "configuration.php";
if(isset($_POST['idexploitation'])){
$idexploitation=$_POST['idexploitation'];
}else{
echo "il y a un pb dans le choix de l'exploitation";
}
$idculture = $_POST["idculture"] ;
$surface="";
$surface=$_POST['surface']; // je recupère la MODIFICATION du champ modifnomVLAN sélectionée par le bouton radio
var_dump($_POST['surface']);
//Initialization value; Examples
//"" When you want to append stuff later
//0 When you want to add numbers later
//if(isset($_POST['surface'])){
//$surface=$_POST['surface'];
//}else{
//echo "il y a un pb dans le choix dela surface";
//}
//if(isset($_POST['surface'])){
//$surface= $_POST['surface'];
//}
if(isset($_POST['rendement'])){
$rendement= $_POST['rendement'];
}
if(isset($_POST['prixvente'])){
$prixvente= $_POST['prixvente'];
}
if(isset($_POST['autresproduits'])){
$autresproduits= $_POST['autresproduits'];
}
if(isset($_POST['idculture'])){
$idculture= $_POST['idculture'];
}
if(isset($_POST['semencesachetes'])){
$semencesachetes= $_POST['semencesachetes'];
}
if(isset($_POST['semencespreleves'])){
$semencespreleves= $_POST['semencespreleves'];
}
if(isset($_POST['totalsemences'])){
$totalsemences= $_POST['totalsemences'];
}
if(isset($_POST['n'])){
$n= $_POST['n'];
}
if(isset($_POST['p']))
{
$p=$_POST['p'];
}
if(isset($_POST['k']))
{
$k=$_POST['k'];
}
if(isset($_POST['s']))
{
$s=$_POST['s'];
}
if(isset($_POST['mg']))
{
$mg=$_POST['mg'];
}
if(isset($_POST['coutfertiorg'])){
$coutfertiorg= $_POST['coutfertiorg'];
}
if(isset($_POST['coutfertimin'])){
$coutfertimin= $_POST['coutfertimin'];
}
if(isset($_POST['amendement'])){
$amendement= $_POST['amendement'];
}
if(isset($_POST['desherbage'])){
$desherbage= $_POST['desherbage'];
}
if(isset($_POST['fongicide'])){
$fongicide= $_POST['fongicide'];
}
if(isset($_POST['insecticide'])){
$insecticide= $_POST['insecticide'];
}
if(isset($_POST['limace'])){
$limace= $_POST['limace'];
}
if(isset($_POST['regulateur'])){
$regulateur= $_POST['regulateur'];
}
if(isset($_POST['divers'])){
$divers= $_POST['divers'];
}
if(isset($_POST['assurancegrele'])){
$assurancegrele= $_POST['assurancegrele'];
}
if(isset($_POST['assurancerecolte'])){
$assurancerecolte= $_POST['assurancerecolte'];
}
if(isset($_POST['sechage'])){
$sechage= $_POST['sechage'];
}
if(isset($_POST['irrigation'])){
$irrigation= $_POST['irrigation'];
}
if(isset($_POST['indemnitegrele'])){
$indemnitegrele= $_POST['indemnitegrele'];
}
if(isset($_POST['aidesproteagineux'])){
$aidesproteagineux= $_POST['aidesproteagineux'];
}
if(isset($_POST['aidesmae'])){
$aidesmae= $_POST['aidesmae'];
}
if(isset($_POST['dpu'])){
$dpu= $_POST['dpu'];
}
if(isset($_POST['totalaides'])){
$totalaides= $_POST['totalaides'];
}
//ini_set("display_errors",0);
//error_reporting(0);
//création de la requête SQL:
//Modification
// on teste si les variables du formulaire sont déclarées
// lancement de la requête
$sql = ("UPDATE cultures SET surface=".$surface." WHERE idexploitation=".$idexploitation." AND millesime = ".$annee." AND idculture = ".$idculture."");
pg_query($sql) or die('Erreur SQL !'.$sql.'');
echo "<img src='images/puce_002.gif'>";
echo "<span class='validation'>LA DONNEE A BIEN ETE ENREGISTREE.<br><br></span>";
// on ferme la connexion à la base
pg_close();
// on ferme la connexion à la base
// un petit message permettant de se rendre compte de la modification effectuée
if($sql)
{
echo("Modifications have been taken into account") ;
}
else
{
echo("La modification à échouée") ;
}
?> |