Bonjour, je suis très débutant en php et je suis entrain de créer un site internet. Je voudrais que les internautes ajoutent des images à partir d'un formulaire sur mon site. Mon problème c'est que je n'arrive pas à faire fonctionner mon formulaire. Voici le code de mon 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
 
<form id="form1" name="form1" method="post" action="enregistrement.php" enctype="multipart/form-data" onsubmit="return VerifMail();">
                                  <table width="100%" border="0" cellpadding="0" bgcolor="#FFFFFF">
                                    <tr>
                                      <td width="35%" align="right"><em><strong>Option d'offre et de Demande</strong></em></td>
                                      <td colspan="2" align="left" valign="bottom"><hr /></td>
                                      </tr>
                                    <tr>
                                      <td align="right">Type d'annonce:</td>
                                      <td width="37%" align="left"><div id="spryradio2">
                                        <table width="200">
                                          <tr>
                                            <td width="85"><label>
                                              <input type="radio" name="RadioGroup2" value="Offre" id="RadioGroup2_0" />
                                              Offre</label></td>
                                            <td width="103"><input type="radio" name="RadioGroup2" value="Demande" id="RadioGroup2_1" />
                                              Demande</td>
                                            </tr>
                                          </table>
                                        <span class="radioRequiredMsg">Effectuez une sélection.</span></div></td>
                                      <td width="28%">&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <td align="right" bgcolor="#FFFFFF"><em><strong>Informations sur votre personne</strong></em></td>
                                      <td colspan="2" align="left" valign="bottom"><hr /></td>
                                      </tr>
                                    <tr>
                                      <td align="right">Vous &ecirc;tes un:</td>
                                      <td align="left"><div id="spryradio1">
                                        <table width="200">
                                          <tr>
                                            <td><label>
                                              <input type="radio" name="RadioGroup1" value="particulier" id="RadioGroup1_0" />
                                              Particulier</label></td>
                                            <td><input type="radio" name="RadioGroup1" value="Professionnel" id="RadioGroup1_1" />
                                              Professionnel</td>
                                          </tr>
                                        </table>
                                        <span class="radioRequiredMsg">Effectuez une s&eacute;lection.</span></div></td>
                                      <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <td align="right" bgcolor="#FFFFFF">Nom et Pr&eacute;noms</td>
                                      <td colspan="2" align="left" valign="bottom"><span id="sprytextfield1">
                                        <label>
                                          <input type="text" name="nom" id="nom" style="text-align:center"/>
                                        </label>
                                        <span class="textfieldRequiredMsg">Une valeur est requise.</span></span></td>
                                    </tr>
                                    <tr>
                                      <td align="right" valign="top" bgcolor="#FFFFFF">Email:</td>
                                      <td colspan="2" align="left" valign="bottom"><span id="sprytextfield2">
                                        <label>
                                          <input type="text" name="email" id="email" style="text-align:center"/>
                                          <span class="textfieldRequiredMsg">Une valeur est requise.</span></label>
</span><br/><em style="font-size:12px; color:#063">Afin de vous protéger du spam, votre email ne sera pas visible dans l'annonce. Les utilisateurs pourront vous contacter via un formulaire.</em></td>
                                    </tr>
                                    <tr>
                                      <td align="right" bgcolor="#FFFFFF">T&eacute;l&eacute;phone cellulaire:</td>
                                      <td colspan="2" align="left" valign="top"><span id="sprytextfield3">
                                        <label>
                                          <input type="text" name="cell" id="cell" style="text-align:center"/>
                                        </label>
                                        <span class="textfieldRequiredMsg">Une valeur est requise.</span></span>ex:(00225)07000100</td>
                                    </tr>
                                    <tr>
                                      <td align="right" bgcolor="#FFFFFF"><em><strong>Informations le produit</strong></em></td>
                                      <td colspan="2" align="left" valign="bottom"><hr /></td>
                                    </tr>
                                    <tr>
                                      <td align="right">Cat&eacute;gorie:</td>
                                      <td align="left"><span id="spryselect1">
                                        <label>
                                          <select name="Category" id="Category">
                                            <?php
do {  
?>
                                            <option value="<?php echo $row_champ1['Idcat']?>"><?php echo $row_champ1['TitrCat']?></option>
                                            <?php
} while ($row_champ1 = mysql_fetch_assoc($champ1));
  $rows = mysql_num_rows($champ1);
  if($rows > 0) {
      mysql_data_seek($champ1, 0);
	  $row_champ1 = mysql_fetch_assoc($champ1);
  }
?>
                                          </select>
                                        </label>
                                        <span class="selectRequiredMsg">S&eacute;lectionnez un &eacute;l&eacute;ment.</span></span></td>
                                      <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <td align="right" bgcolor="#FFFFFF">Appelation de votre produit::</td>
                                      <td colspan="2" align="left" valign="bottom"><span id="sprytextfield4">
                                        <label>
                                          <input type="text" name="produit" id="produit" style="text-align:center"/>
                                        </label>
                                        <span class="textfieldRequiredMsg">Une valeur est requise.</span></span>ex:Radio</td>
                                    </tr>
                                    <tr>
                                      <td align="right" valign="top" bgcolor="#FFFFFF">D&eacute;tails de votre annonce::</td>
                                      <td colspan="2" align="left" valign="bottom"><span id="sprytextarea1">
                                        <label>
                                          <textarea name="detail" id="detail" cols="45" rows="5"></textarea>
                                        </label>
                                        <span class="textareaRequiredMsg">Une valeur est requise.</span></span></td>
                                    </tr>
                                    <tr>
                                      <td align="right" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
                                      <td colspan="2" align="left" valign="bottom"><em style="font-size:12px; color:#063">Indiquez dans l'annonce si vous d&eacute;sirez &ecirc;tre contact&eacute;(e) uniquement 
                                          par t&eacute;l&eacute;phone.</em> </td>
                                    </tr>
                                    <tr>
                                      <td align="right" valign="top" bgcolor="#FFFFFF">Prix de vente de votre produit:</td>
                                      <td colspan="2" align="left" valign="bottom"><span id="sprytextfield5">
                                        <label>
                                          <input type="text" name="cout" id="cout" style="text-align:center"/>
                                        </label>
                                        <span class="textfieldRequiredMsg">Une valeur est requise.</span></span>en &euro; ou Fcfa ex:15&euro;</td>
                                    </tr>
                                    <tr>
                                      <td align="right" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
                                      <td colspan="2" align="left" valign="bottom"><input type="hidden" name="MAX_FILE_SIZE" value="100000"><input type="file" name="imag" size="30"></td>
                                    </tr>
                                    <tr>
                                      <td align="right" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
                                      <td colspan="2" align="left" valign="bottom"><em style="font-size:12px; color:#063"><span style="color: rgb(0, 0, 255);">info : une annonce avec photos 
                                            est 7 fois plus consult&eacute;e qu'une annonce sans photo.</span> <br />
Les photos aux formats jpg, gif, png et bmp sont ajust&eacute;es 
                                          automatiquement. Le t&eacute;l&eacute;chargement de photos en bas d&eacute;bit peut prendre 
                                          du temps</em></td>
                                    </tr>
                                    <tr>
                                      <td align="right" valign="top" bgcolor="#FFFFFF"><em><strong>Validation</strong></em></td>
                                      <td colspan="2" align="left" valign="bottom"><hr /></td>
                                    </tr>
                                    <tr>
                                      <td align="right" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
                                      <td colspan="2" align="left" valign="bottom"><label>
                                        <input type="reset" name="effacer" id="Valider" value="Effacer" /></label><label><input type="submit" name="Valider" id="Valider" value="Valider" />
                                      </label></td>
                                    </tr>
                                  </table>
                                </form>
 
 
Aussi, j'ai fouiller sur le net pour chercher des tutoriel mail, je n'arrive pas à les faire fonctionner. Voici par exemple des portions de code que j'ai trouvé sur le net:
 
<?php
$_FILES['icone']['name']     //Le nom original du fichier, comme sur le disque du visiteur, (exemple: mon_icone.png).
$_FILES['icone']['type']     //Le type du fichier. Par exemple, cela peut être "image/png"
$_FILES['icone']['size']     //La taille du fichier en octets
$_FILES['icone']['tmp_name'] //L'adresse vers le fichier uploadé dans le répertoire temporaire
$_FILES['icone']['error']    //Le code d'erreur, qui permet de savoir si le fichier a bien été uploadé
?>
 
<?php
if ($_FILES['icone']['error'] > 0) $erreur = "Erreur lors du transfert";
?>
<?php
if ($_FILES['icone']['size'] > $maxsize) $erreur = "Le fichier est trop gros";
?>
 
<?php
$extensions_valides = array( 'jpg' , 'jpeg' , 'gif' , 'png' );
//1. strrchr renvoie l'extension avec le .
//2. substr(chaine,1) ignore le premier caractère de chaine
//3. strtolower met l'extension en minuscule
$extension_upload = strtolower(  substr(  strrchr($_FILES['icone']['name'], '.')  ,1)  );
if ( in_array($extension_upload,$extensions_valides) ) echo "Extension correcte";
?>
 
<?php
//Créer un dossier 'fichiers/1/'
  mkdir('fichier/1/', 0777, true);
 
//Créer un identifiant difficile à deviner
  $nom = md5(uniqid(rand(), true));
?>
 
<?php
$nom = "avatars/{$id_membre}.{$extension_upload}";
$resultat = move_uploaded_file($_FILES['icone']['tmp_name'],$nom);
if ($resultat) echo "Transfert réussi";
?>
et que j'ai du mal à assembler et à faire fonctionner. Je demande votre aide . Merci d'avance.