Bonjour,

Je suis entrain de faire un petit applicatif personnel de gestion de courrier avec Dreamweaver. Je rencontre un souci avec un champ fichier.
Lorsque je choisis mon fichier avec le bouton "Parcourir" et lorsque j'appuie sur le bouton "Valider", le fichier est bien uploadé au niveau du répertoire souhaité mais le nom du fichier n'est pas sauvegardé au niveau de la base MySql. J'ai le message suivant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
Notice: Undefined index: files in C:\Program Files\EasyPHP-5.3.9\www\fastdelivery\Infos_Mail_Arrived.php on line 242
Le champ 'fichier' ne peut être vide (null)
La ligne 242 correspond à la ligne du "GetSQLValueString($_POST['files'], "text"));" du code d'insertion dans la base MySql après le code ci-dessous.

Voici le code du formulaire :

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
 
 <form action="<?php echo $editFormAction; ?>" id="saisie" method="post"  enctype="multipart/form-data">
			      <table width="900" border="0">
				      <tr>
				        <td colspan="2" bgcolor="#99FF99"><strong>Informations d'Identification</strong></td>
			          </tr>
				      <tr>
				        <td><h6>Les champs munis d'un (*) sont obligatoires.</h6></td>
				        <td><?php 
if (isset($_POST['reference']))
{
	echo "<font color='orange'> Nouvelles données enregistrées.</font>";
	}
?></td>
			          </tr>
				      <tr>
				        <td><input name="user" type="hidden" id="user" value="<?php echo $row_session['user']; ?>" />
			            Référence courrier*</td>
				        <td><span id="sprytextfield1">
				          <input name="reference" type="text" id="reference" value="<?php echo "CA-", date('ymdHis'); ?>" size="50" readonly />
			            <span class="textfieldRequiredMsg">Obligatoire.</span></span></td>
			          </tr>
				      <tr>
				        <td>Coordonnées Expéditeurs*</td>
				        <td><span id="sprytextarea1">
				          <textarea name="coordonnees" cols="60" rows="5" id="coordonnees"></textarea>
			            <span class="textareaRequiredMsg">Obligatoire.</span></span></td>
			          </tr>
				      <tr>
				        <td>Type*</td>
				        <td><span id="spryselect1">
				          <select name="type" id="type">
				            <?php
do {  
?>
				            <option value="<?php echo $row_types['type']?>"><?php echo $row_types['type']?></option>
				            <?php
} while ($row_types = mysql_fetch_assoc($types));
  $rows = mysql_num_rows($types);
  if($rows > 0) {
      mysql_data_seek($types, 0);
	  $row_types = mysql_fetch_assoc($types);
  }
?>
		                </select>
			            <span class="selectRequiredMsg">Faites un choix.</span></span></td>
			          </tr>
				      <tr>
				        <td>Nature*</td>
				        <td><span id="spryselect2">
				          <select name="nature" id="nature">
				            <?php
do {  
?>
				            <option value="<?php echo $row_natures['nature']?>"><?php echo $row_natures['nature']?></option>
				            <?php
} while ($row_natures = mysql_fetch_assoc($natures));
  $rows = mysql_num_rows($natures);
  if($rows > 0) {
      mysql_data_seek($natures, 0);
	  $row_natures = mysql_fetch_assoc($natures);
  }
?>
		                </select>
			            <span class="selectRequiredMsg">Faites un choix.</span></span></td>
			          </tr>
				      <tr>
				        <td>Date d'arrivée du courrier*</td>
				        <td><span id="sprytextfield2">
                        <input name="date_arrivee" type="text" id="date_arrivee" onclick="ds_sh(this);" readonly />
                        <span class="textfieldRequiredMsg">Obligatoire.</span></span></td>
			          </tr>
				      <tr>
				        <td>Date de création dans le système*</td>
				        <td><span id="sprytextfield3">
				          <input name="date_creation" type="text" id="date_creation" onclick="ds_sh(this);" readonly />
			            <span class="textfieldRequiredMsg">Obligatoire.</span></span></td>
			          </tr>
				      <tr>
				        <td>Unité administrative*</td>
				        <td><span id="spryselect3">
				          <select name="ua_cible" id="ua_cible">
				            <?php
do {  
?>
				            <option value="<?php echo $row_uas['nom']?>"><?php echo $row_uas['nom']?></option>
				            <?php
} while ($row_uas = mysql_fetch_assoc($uas));
  $rows = mysql_num_rows($uas);
  if($rows > 0) {
      mysql_data_seek($uas, 0);
	  $row_uas = mysql_fetch_assoc($uas);
  }
?>
		                </select>
			            <span class="selectRequiredMsg">Faites un choix.</span></span></td>
			          </tr>
				      <tr>
				        <td>Suivi par*</td>
				        <td><span id="sprytextfield4">
				          <input name="person_ua" type="text" id="person_ua" size="50" />
			            <span class="textfieldRequiredMsg">Obligatoire.</span></span></td>
			          </tr>
				      <tr>
				        <td>Objet du courrier*</td>
				        <td><span id="sprytextarea2">
				          <textarea name="objet" cols="50" id="objet"></textarea>
			            <span class="textareaRequiredMsg">Obligatoire.</span></span></td>
			          </tr>
				      <tr>
				        <td>Commentaires</td>
				        <td><span id="sprytextarea3">
				          <textarea name="comments" cols="60" rows="5" id="comments"></textarea>
</span></td>
			          </tr>
				      <tr>
				        <td>&nbsp;</td>
				        <td>&nbsp;</td>
			          </tr>
				      <tr>
				        <td colspan="2" bgcolor="#99FF99"><strong>Informations de gestion des ampliations</strong></td>
			          </tr>
				      <tr>
				        <td>&nbsp;</td>
				        <td>&nbsp;</td>
			          </tr>
				      <tr>
				        <td>Unité administrative pour traitement*</td>
				        <td><span id="spryselect4">
				          <select name="ua_traitement" id="ua_traitement">
				            <?php
do {  
?>
				            <option value="<?php echo $row_uas['nom']?>"><?php echo $row_uas['nom']?></option>
				            <?php
} while ($row_uas = mysql_fetch_assoc($uas));
  $rows = mysql_num_rows($uas);
  if($rows > 0) {
      mysql_data_seek($uas, 0);
	  $row_uas = mysql_fetch_assoc($uas);
  }
?>
		                </select>
			            <span class="selectRequiredMsg">Faites un choix.</span></span></td>
			          </tr>
				      <tr>
				        <td>Unité administrative 1 en copie</td>
				        <td><select name="ua_copie1" id="ua_copie1">
				          <?php
do {  
?>
				          <option value="<?php echo $row_uas['nom']?>"><?php echo $row_uas['nom']?></option>
				          <?php
} while ($row_uas = mysql_fetch_assoc($uas));
  $rows = mysql_num_rows($uas);
  if($rows > 0) {
      mysql_data_seek($uas, 0);
	  $row_uas = mysql_fetch_assoc($uas);
  }
?>
                        </select></td>
			          </tr>
				      <tr>
				        <td>Unité administrative 2 en copie</td>
				        <td><select name="ua_copie2" id="ua_copie2">
				          <?php
do {  
?>
				          <option value="<?php echo $row_uas['nom']?>"><?php echo $row_uas['nom']?></option>
				          <?php
} while ($row_uas = mysql_fetch_assoc($uas));
  $rows = mysql_num_rows($uas);
  if($rows > 0) {
      mysql_data_seek($uas, 0);
	  $row_uas = mysql_fetch_assoc($uas);
  }
?>
                        </select></td>
			          </tr>
				      <tr>
				        <td>Unité administrative 3 en copie</td>
				        <td><select name="ua_copie3" id="ua_copie3">
				          <?php
do {  
?>
				          <option value="<?php echo $row_uas['nom']?>"><?php echo $row_uas['nom']?></option>
				          <?php
} while ($row_uas = mysql_fetch_assoc($uas));
  $rows = mysql_num_rows($uas);
  if($rows > 0) {
      mysql_data_seek($uas, 0);
	  $row_uas = mysql_fetch_assoc($uas);
  }
?>
                        </select></td>
			          </tr>
				      <tr>
				        <td>&nbsp;</td>
				        <td>&nbsp;</td>
			          </tr>
				      <tr>
				        <td colspan="2" bgcolor="#99FF99"><strong>Gestion électronique du courrier</strong></td>
			          </tr>
				      <tr>
				        <td>&nbsp;</td>
				        <td>&nbsp;</td>
			          </tr>
				      <tr>
				        <td>Fichier électronique du courrier* (pdf)</td>
				        <td><input name="files" type="file" class="nav-divider" id="files" size="50" /></td>
			          </tr>
				      <tr>
				        <td>&nbsp;</td>
				        <td>&nbsp;</td>
			          </tr>
				      <tr>
				        <td>&nbsp;</td>
				        <td><input border='0' src="images/validate.jpg" type="image" value="submit" align="middle" width='125' height='32'/> 
				           <input name="reset" border='0' src="images/reset.jpg" type="image" align="middle" width='125' height='32' onclick="document.form1.reset();return false;"/></td>
			          </tr>
		          </table>
			      <input type="hidden" name="MM_insert" value="saisie" />
		        </form>
Voici le code pour insérer le nom du fichier dans la base MySql :

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
 
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "saisie")) {
  $insertSQL = sprintf("INSERT INTO incoming_mail (`user`, reference, coordonnees, type, nature, date_arrivee, date_creation, ua_cible, person_ua, objet, comments, ua_traitement, ua_copie1, ua_copie2, ua_copie3, fichier) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['user'], "text"),
                       GetSQLValueString($_POST['reference'], "text"),
                       GetSQLValueString($_POST['coordonnees'], "text"),
                       GetSQLValueString($_POST['type'], "text"),
                       GetSQLValueString($_POST['nature'], "text"),
                       GetSQLValueString($_POST['date_arrivee'], "text"),
                       GetSQLValueString($_POST['date_creation'], "text"),
                       GetSQLValueString($_POST['ua_cible'], "text"),
                       GetSQLValueString($_POST['person_ua'], "text"),
                       GetSQLValueString($_POST['objet'], "text"),
                       GetSQLValueString($_POST['comments'], "text"),
                       GetSQLValueString($_POST['ua_traitement'], "text"),
                       GetSQLValueString($_POST['ua_copie1'], "text"),
                       GetSQLValueString($_POST['ua_copie2'], "text"),
                       GetSQLValueString($_POST['ua_copie3'], "text"),
                       GetSQLValueString($_POST['files'], "text"));
 
  mysql_select_db($database_conn, $conn);
  $Result1 = mysql_query($insertSQL, $conn) or die(mysql_error());
}
Merci de votre précieuse aide.