Bonjour ,

J'ai une page avec un formulaire qui mène vers une seconde page .
Dans cette dernière , j'uploade 2 photos en meme temps , et je mets à jour le formulaire de la première page .
Tout est nickel ...sauf que dans ma BDD , je me retrouve avec 2 id :

- celui créé par la première page : par exemple , il porte le numéro 40
- celui créé dans la seconde : il porte le numéro 41 ( et il me convient parfaitement )

Pbs : je ne sais pas pourquoi j'obtiens cet id 41 au lieu du seul 40 mis à jour .

Une idée ?

Sinon , comment faire pour supprimer le 40 après la validation du formulaire dans la seconde page ?

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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<?php require_once('../Connections/facevspile.php'); ?><?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
 
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE shop_monnaies SET rubannu1=%s, rubannu2=%s, rubannu3=%s, prix_ttc=%s, avers=%s, revers=%s, etat=%s, poids=%s, diametre=%s, metal=%s, prix_ht=%s, `photo a`=%s, `photo b`=%s, frais_de_port=%s, commission=%s, titre=%s, date_vente=%s, valeur=%s, commentaires=%s WHERE id=%s",
                       GetSQLValueString($_POST['rubannu1'], "int"),
                       GetSQLValueString($_POST['rubannu2'], "int"),
                       GetSQLValueString($_POST['rubannu3'], "int"),
                       GetSQLValueString($_POST['prix_ttc'], "double"),
                       GetSQLValueString($_POST['avers'], "text"),
                       GetSQLValueString($_POST['revers'], "text"),
                       GetSQLValueString($_POST['etat'], "text"),
                       GetSQLValueString($_POST['poids'], "double"),
                       GetSQLValueString($_POST['diametre'], "text"),
                       GetSQLValueString($_POST['metal'], "text"),
                       GetSQLValueString($_POST['prix_ht'], "double"),
                       GetSQLValueString($_POST['photo_a'], "text"),
                       GetSQLValueString($_POST['photo_b'], "text"),
                       GetSQLValueString($_POST['frais_de_port'], "double"),
                       GetSQLValueString($_POST['commission'], "double"),
                       GetSQLValueString($_POST['titre'], "text"),
                       GetSQLValueString($_POST['date_vente'], "date"),
                       GetSQLValueString($_POST['valeur'], "int"),
                       GetSQLValueString($_POST['commentaires'], "text"),
                       GetSQLValueString($_POST['id'], "int"));
 
  mysql_select_db($database_facevspile, $facevspile);
  $Result1 = mysql_query($updateSQL, $facevspile) or die(mysql_error());
 
  $updateGoTo = "index.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
 
 
mysql_select_db($database_facevspile, $facevspile);
$query_Recordset10 = "SELECT * FROM shop_monnaies ORDER BY id desc limit 0,1";
$Recordset10 = mysql_query($query_Recordset10, $facevspile) or die(mysql_error());
$row_Recordset10 = mysql_fetch_assoc($Recordset10);
$totalRows_Recordset10 = mysql_num_rows($Recordset10);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 
<div id="apDiv19" style="position:absolute; width:950px; height:115px; z-index:10; left: 22px; top: 218px;">
<form method="POST" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" enctype="multipart/form-data"> <fieldset> <legend>Transf&eacute;rer vos images </legend>
     <p>
       <input type="hidden" name="MAX_FILE_SIZE" value="2000000">
       Sélectionner votre image de l'avers :
       <input type="file" name="avatar">
     </p>
     <p> Sélectionner votre image du revers :
       <input type="file" name="av">
      </p>
     <p>
       <input type="submit" name="ok" id="ok" value="T&eacute;l&eacute;charger les 2 photos " /> 
               </p>
</fieldset> 
</form> <?php if (isset($_FILES['avatar']['name'])) {
// traitement
$dossier = 'images/avers/';
$fichier = basename($_FILES['avatar']['name']);
$taille_maxi = 2000000;
$taille = filesize($_FILES['avatar']['tmp_name']);
$extensions = array('.jpg', '.jpeg');
$extension = strrchr($_FILES['avatar']['name'], '.'); 
 
//Début des vérifications de sécurité...
if(!in_array($extension, $extensions)) //Si l'extension n'est pas dans le tableau
{
     $erreur = 'Vous devez télécharger un fichier de type  jpg ...';
}
if($taille>$taille_maxi)
{
     $erreur = 'Le fichier est trop gros...';
}
if(!isset($erreur)) //S'il n'y a pas d'erreur, on upload
{
     //On formate le nom du fichier ici...
     $fichier = strtr($fichier, 
          'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ', 
          'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
     $fichier = preg_replace('/([^.a-z0-9]+)/i', '-', $fichier);
	 $time = date("YmdHis");
	 $S = substr(md5($fichier.$time),0,15);
	 $Nom = $S.".jpg";
     if(move_uploaded_file($_FILES['avatar']['tmp_name'], $dossier . $Nom)) //Si la fonction renvoie TRUE, c'est que ça a fonctionné...
     {
          echo 'Téléchargement effectué avec succès !';
     }
     else //Sinon (la fonction renvoie FALSE).
     {
          echo 'Echec du téléchargement !';
     }
}
else
{
     echo $erreur;
}
}
 
 
?>
<?php if (isset($_FILES['av']['name'])) {
// traitement
$dossier = 'images/avers/';
$fichier = basename($_FILES['av']['name']);
$taille_maxi = 2000000;
$taille = filesize($_FILES['av']['tmp_name']);
$extensions = array('.jpg', '.jpeg');
$extension = strrchr($_FILES['av']['name'], '.'); 
 
//Début des vérifications de sécurité...
if(!in_array($extension, $extensions)) //Si l'extension n'est pas dans le tableau
{
     $erreur = 'Vous devez télécharger un fichier de type  jpg ...';
}
if($taille>$taille_maxi)
{
     $erreur = 'Le fichier est trop gros...';
}
if(!isset($erreur)) //S'il n'y a pas d'erreur, on upload
{
     //On formate le nom du fichier ici...
     $fichier = strtr($fichier, 
          'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ', 
          'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
     $fichier = preg_replace('/([^.a-z0-9]+)/i', '-', $fichier);
	 $time = date("YmdHis");
	 $T = substr(md5($fichier.$time),0,15);
	 $Nom = $T.".jpg";
     if(move_uploaded_file($_FILES['av']['tmp_name'], $dossier . $Nom)) //Si la fonction renvoie TRUE, c'est que ça a fonctionné...
     {
          echo '';
     }
     else //Sinon (la fonction renvoie FALSE).
     {
          echo 'Echec du téléchargement !';
     }
}
else
{
     echo $erreur;
}
}
 
 
?>
      </div>
      <p>&nbsp;</p>
 
      <p>&nbsp;</p>
      <div id="apDiv20" style="position:absolute; width:950px; height:618px; z-index:11; left: 22px; top: 476px;">
        <p>&nbsp;</p>
 
 
 
 
        <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
          <table align="center">
            <tr valign="baseline">
              <td nowrap="nowrap" align="right">Prix_ttc:</td>
              <td><input type="text" name="prix_ttc" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right">Etat:</td>
              <td><input type="text" name="etat" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right">Poids:</td>
              <td><input type="text" name="poids" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right">Diametre:</td>
              <td><input type="text" name="diametre" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right">Metal:</td>
              <td><input type="text" name="metal" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right">Commentaires:</td>
              <td><input type="text" name="commentaires" size="32" /></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right">&nbsp;</td>
              <td><input type="submit" value="Valider" /></td>
            </tr>
          </table>
          <input type="hidden" name="date_vente" value="<?php echo $row_Recordset10['date_vente']; ?>" size="32" />
          <input type="hidden" name="rubannu1" value="<?php echo htmlentities($row_Recordset10['rubannu1'], ENT_COMPAT, 'iso-8859-1'); ?>" />
          <input type="hidden" name="rubannu2" value="<?php echo htmlentities($row_Recordset10['rubannu2'], ENT_COMPAT, 'iso-8859-1'); ?>" />
          <input type="hidden" name="rubannu3" value="<?php echo htmlentities($row_Recordset10['rubannu3'], ENT_COMPAT, 'iso-8859-1'); ?>" />
          <input type="hidden" name="avers" value="a" />
          <input type="hidden" name="revers" value="b" />
          <input type="hidden" name="prix_ht" value="10" />
          <input type="hidden" name="photo_a" value="<?php echo($S); ?>" />
          <input type="hidden" name="photo_b" value="<?php echo ($T); ?>" />
          <input type="hidden" name="frais_de_port" value="3" />
          <input type="hidden" name="commission" value="1" />
          <input type="hidden" name="titre" value="<?php echo htmlentities($row_Recordset10['titre'], ENT_COMPAT, 'iso-8859-1'); ?>" />
          <input type="hidden" name="valeur" value="<?php echo htmlentities($row_Recordset10['valeur'], ENT_COMPAT, 'iso-8859-1'); ?>" />
          <input type="hidden" name="MM_update" value="form1" />
          <input type="hidden" name="id" value="<?php echo $row_Recordset10['id']; ?>" />
        </form>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
      </div>
 
<?php
mysql_free_result($Recordset10);
?>
HAbroc