Précédent   Forum des professionnels en informatique > PHP > Langage > Formulaires
Formulaires Forum d'entraide sur les formulaires avec PHP. Avant de poster -> FAQ formulaires, Cours de formulaires et Sources de formulaires
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 02/03/2008, 08h18   #1
Membre du Club
 
Inscription : février 2008
Messages : 149
Détails du profil
Informations forums :
Inscription : février 2008
Messages : 149
Points : 45
Points : 45
Par défaut Mauvaise récupération des valeurs avec $_POST

Bonjour à Tous,

A partir d'un formulaire sous EasyPHP, je récupère 15 valeurs de champ en utilisant $_POST.

Les 9ème et 10ème valeur me revoient systématiquement la valeur du 1er champ.

? Quelle explication et quelle solution à ce phénomène.

Merci de votre réponse.

cordialement.
Trebor_ est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/03/2008, 09h35   #2
Membre émérite
 
Avatar de sharrascript
 
Homme Franck
Développeur Web indépendant
Inscription : avril 2007
Messages : 678
Détails du profil
Informations personnelles :
Nom : Homme Franck
Âge : 31
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Développeur Web indépendant

Informations forums :
Inscription : avril 2007
Messages : 678
Points : 900
Points : 900
Bonjour,

Un petit bout de code nous aiderait un peu plus

Cordialement
Sharr
__________________
LudiKreation Pour un web ludique et son Blog | CapRumbo pour un peu d'évasion | ChaOdisiaque Club Passion Rôliste |SierrElben le Jeu de rôle
sharrascript est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/03/2008, 10h33   #3
Membre du Club
 
Inscription : février 2008
Messages : 149
Détails du profil
Informations forums :
Inscription : février 2008
Messages : 149
Points : 45
Points : 45
Par défaut Mauvaise récupération des valeurs avec $_POST

À la demande de SHARR, voici le script.

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
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
 
 
<?PHP
    session_start();
 
    /* Tableau Des Légendes De Champs */
    $Labels = array ("NomEtablissement"  => "Nom De L'Établissement",
                     "Siret   "          => "Siret",
                     "Civilite"          => "Civilité",
                     "Nom"               => "Nom",
                     "Prenom"            => "Prénom(s)",
                     "DateDeNaissance"   => "Date De Naissance",
                     "Adresse"           => "Adresse",
                     "Adresse_"          => "Adresse",
                     "CodePostal"        => "Code Postal",
                     "Ville"             => "Ville",
                     "Pays"              => "Pays",
                     "TelephoneFixe"     => "Téléphone Fixe",
                     "TelephoneMobile"   => "Téléphone Mobile",
                     "Fax"               => "Fax",
                     "AdresseCourrielle" => "Adresse Courrielle",
                     "MotDePasse"        => "Mot De Passe",
                     "MotDePasse_"       => "Mot De Passe");
 
    if (!isset($_POST['Submit'])) 
        { $Message = ""; }
 
    elseif ($_POST['Submit'] == true)  
          /* Scrutation: Contrôle De Véracité */             
        { foreach ($_POST as $Champ => $Valeur)
            { if ($Champ == "NomEtablissement" or 
                  $Champ == "Nom" or 
                  $Champ == "Prenom" or 
                  $Champ == "Ville")
                { if (!Ereg("^[A-Za-z' -]{1,50}$",$Valeur))
                    { $TableFormat[] = $Champ; 
                      $Message = "Nom, Prénom ou Ville: Caractères Invalides"; } }
              elseif ($Champ == "Siret" and $Champ <> "")
                { if (!Ereg("^[A-Za-z0-9 ]{14,17}$",$Valeur))
                    { $TableFormat[] = $Champ; 
                      $Message = "Date De Naissance: Composition Invalide"; } }
              elseif ($Champ == "DateDeNaissance" and $Champ <> "")
                { if (!Ereg("^[1850-2008]{4,4}\.[01-12]{2,2}\.[01-31]{2,2}$",$Valeur))
                    { $TableFormat[] = $Champ; 
                      $Message = "Date De Naissance: Composition Invalide"; } }
              elseif (($Champ == "Adresse") or 
                      ($Champ == "Adresse_" and $Champ <> ""))
                { if (!Ereg("^[0-9 ,]{1,4}[A-Za-z' -]{3,46}$",$Valeur))
                    { $TableFormat[] = $Champ;
                      $Message = "Adresse: Caractères Invalides"; } }
              elseif ($Champ == "CodePostal")
                { if (!Ereg("^[0-9 ]{4,5}$",$Valeur))
                    { $TableFormat[] = $Champ;
                      $Message = "Code Postal: Caractères Invalides"; } }
              elseif (($Champ == "Telephone" and $Champ <> "") or 
                      ($Champ == "Telephone_" and $Champ <> "") or 
                      ($Champ == "Fax" and $Champ <> ""))
                { if (!Ereg("^[0-9.+ -]{1,15}$",$Valeur))
                    { $TableFormat[] = $Champ;
                      $Message = "Téléphone ou Fax: Caractères Invalides"; } }
              elseif ($Champ == "AdresseCourrielle")
                { if (!Ereg("^.+@.+\.com$",$Valeur))
                    { $TableFormat[] = $Champ;
                      $Message = "Adresse Courrielle: Composition Invalides"; } }
              elseif ($Champ == "MotDePasse" or 
                      $Champ == "MotDePasse_")
                { if (!Ereg("^[A-Za-z0-9]{8,8}$",$Valeur))
                    { $TableFormat[] = $Champ;
                      $Message = "Mot De Passe: Caractères Invalides"; } } }
/*            if (@SizeOf($TableFormat) > 0)
                { $Message = "Certaines valeurs ne sont pas conformes au mode de saisie"; } */
          /* Scrutation: Test Si Champ Non Renseigné */  
          foreach ($_POST as $Champ => $Valeur)
            { if ($Champ != "DateDeNaissance" and 
                  $Champ != "Adresse_" and
                  $Champ != "TelephoneFixe" and
                  $Champ != "TelephoneMobile" and
                  $Champ != "Fax")
                { if ($Valeur == "" )
                    { $TableVide[] = $Champ; } } }
            if (@sizeof($TableVide) > 0)
                { $Message = "Il faut saisir l’ensemble des champs spécifiés d’un astérisque"; } }
 
    foreach ($Labels as $Champ => $Label)
        { if (!isset($_POST['Submit']))
              { FOR ($i=0; $i<17; $i++)
                      { $ChampOK[$i] = ""; } }
          else
              { $ChampOK[] = strip_tags(trim($_POST[$Champ])); } }
/*     if (!isset($_POST['Submit']))
        { FOR ($i=0; $i<15; $i++)
                { $ChampOK[$i] = ""; } } */
/*    else
        { $ChampOK[00] = strip_tags(trim($_POST['Civilite']));
          $ChampOK[01] = strip_tags(trim($_POST['Nom']));
          $ChampOK[02] = strip_tags(trim($_POST['Prenom']));
          $ChampOK[03] = strip_tags(trim($_POST['DateDeNaissance']));
          $ChampOK[04] = strip_tags(trim($_POST['Adresse']));
          $ChampOK[05] = strip_tags(trim($_POST['Adresse_']));
          $ChampOK[06] = strip_tags(trim($_POST['CodePostal']));
          $ChampOK[07] = strip_tags(trim($_POST['Ville']));
          $ChampOK[08] = strip_tags(trim($_POST['Pays']));
          $ChampOK[09] = strip_tags(trim($_POST['TelephoneFixe']));
          $ChampOK[10] = strip_tags(trim($_POST['TelephoneMobile']));
          $ChampOK[11] = strip_tags(trim($_POST['Fax']));
          $ChampOK[12] = strip_tags(trim($_POST['AdresseCourrielle']));
          $ChampOK[13] = strip_tags(trim($_POST['MotDePasse']));
          $ChampOK[14] = strip_tags(trim($_POST['MotDePasse_'])); }
    echo $ChampOK[08]; *
?>
 
<!DOCTYPE HTML public "-//W3C//DTD HTML 4.01 Transitional//EN" "Http://www.w3.org/TR/html4/Loose.dtd">
 
<HTML>
 
    <HEAD>
 
        <TITLE> STYLO PLUME </TITLE>
 
        <META HTTP-EQUIV="Content-Type" CONTENT="Text/html; charset=ISO-8859-1" />
<!--            <META HTTP-EQUIV="Content-Type" CONTENT="Text/html; charset=UTF-8" /> -->
        <META Name="Auteur" Content="Robert  R.  ROUSSEAU" />
        <MATA Name="Version" Content="2008.01" />
 
        <LINK rel="StyleSheet" type="Text/CSS" href="Particulier.css">
 
<SCRIPT>
 
    function Clignotement()
        { if (document.getElementById("MonElement").style.display=="block")
              document.getElementById("MonElement").style.display="none";
          else
              document.getElementById("MonElement").style.display="block"; }
 
// appel de la fonction toutes les 0.5 secondes
    setInterval("Clignotement()", 1000);
 
</SCRIPT>
 
    </head>
 
    <body bgcolor="#FFFFFF" width="846" height="536" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
 
        <p align="Center">
            <font color="#0000C0" size="5"><b> MON COMPTE </b></font>
                <font color="#0000C0" size="5"><i> (Particulier) </i></font><br />
        </p>
        <p align="Center">
            <font color="#FF0000"> Remarque: </font>
            <font color="#0000C0"> Si vous êtes déjà enregistré(e), 
                                            veuillez vous identifier 
                                            à la page d'accueil précédente </font>
        </p>
 
        <?php
/*            Echo "Début"; */
/*            Echo "PHPSessionID = {$_SESSION['PHPSessionID']}<br>\n"; */
/*            Echo "Nom = {$_SESSION['Nom']}<br>\n"; */
 
            if ($Message <> "")
                { echo "<TABLE>
                            <TR>
                                <TD><FONT color='#0000FF'> MESSAGE: </FONT></TD>
                                <TD id='MonElement' class='EX_div'>
                                        <FONT color='#FF0000'> $Message </FONT></TD>
                            </TR>
                        </TABLE>"; }
 
        ?>
 
        <form action="Professionnel_.php" method="POST">
            <table align="Center">
 
                <tbody>
                    <tr>
                        <th align="Right"><font  color="#FF0000"> * </font> Nom De L’Établissement: </th>
                        <td align="Left">
                            <input tabindex="00" type="Text" value="<?php echo $ChampOK[00]; ?>" size="25" maxlength="100">
                            </font> (Format: A-Z a-z ' Espace -) </font>
                        </td>
                    </tr>
                    <tr>
                        <th align="Right"><font  color="#FF0000"> * </font> SIRET: </th>
                        <td align="Left">
                            <input tabindex="01" type="Text" value="<?php echo $ChampOK[01]; ?>" size="25" maxlength="50">
                            </font> (Format: A-Z a-z 9 Espace) </font>
                        </td>
                    </tr>
                    <tr>
                        <td><br /><br />
                        </td>
                    </tr>
                    <tr>
                        <th align="Right"><font color="#FF0000"> * </font> Civilité: </th>
                        <td><label>
                            <select name="Civilite">
                                <option Value="Mme" <?php echo ($ChampOK[02]=='Mme') ? ' selected="selected"' : ''; ?> > Madame </option>
                                <option Value="Mlle" <?php echo ($ChampOK[02]=='Mlle') ? ' selected="selected"' : ''; ?> > Mademoiselle </option>
                                <option Value="Mr" <?php echo ($ChampOK[02]=='Mr') ? ' selected="selected"' : ''; ?> > Monsieur </option>
                            </select>
                            </label>
                        </td>
                    </tr>
                    <tr>
                        <th align="Right"><font color="#FF0000"> * </font> Nom: </th>
                        <td align="Left">
                            <input type="Text" name="Nom" value="<?php echo $ChampOK[03]; ?>" size="25" maxlength="50">
                            </font> (Format: A-Z a-z ' Espace -) </font>
                        </td>
                    </tr>
                    <tr>
                        <th align="Right"><font color="#FF0000"> * </font> Prénom(s): </th>
                        <td align="Left">
                            <input type="Text" name="Prenom" value="<?php echo $ChampOK[04]; ?>" size="25" maxlength="50">
                            </font> (Format: A-Z a-z ' Espace -) </font>
                        </td>
                    </tr>
                    <tr>
                        <th align="Right"> Date De Naissance: </th>
                        <td align="Left">
                            <input type="Text" name="DateDeNaissance" value="<?php echo $ChampOK[05]; ?>" size="25" maxlength="50">
                            </font> (Format: AAAA.MM.JJ) </font>
                        </td>
                    </tr>
                    <tr>
                        <td><br /><br />
                        </td>
                    </tr>
                    <tr>
                        <th align="Right"><font color="#FF0000"> * </font> Adresse: </th>
                        <td align="Left">
                            <input type="Text" name="Adresse" value="<?php echo $ChampOK[06]; ?>" size="75" maxlength="150">
                            </font> (Format: 9 , A-Z a-z ' Espace -) </font>
                        </td>
                    </tr>
                    <tr>
                        <th align="Right"> Complément D’Adresse: </th>
                        <td align="Left">
                            <input type="Text" name="Adresse_" value="<?php echo $ChampOK[07]; ?>" size="75" maxlength="150">
                            </font> (Format: 9 , A-Z a-z ' Espace -) </font>
                        </td>
                    </tr>
                    <tr>
                        <th align="Right"><font color="#FF0000"> * </font> Code Postal: </th>
                        <td align="Left">
                            <input type="Text" name="CodePostal" value="<?php echo $ChampOK[08]; ?>" size="5" maxlength="5">
                            </font> (Format: 9) </font>
                        </td>
                    </tr>
                    <tr>
                        <th align="Right"><font color="#FF0000"> * </font> Ville: </th>
                        <td align="Left">
                            <input type="Text" name="Ville" value="<?php echo $ChampOK[09]; ?>" size="25" maxlength="50">
                            </font> (Format: A-Z a-z ' Espace -) </font>
                        </td>
                    </tr>
                    <tr>
                        <th align="Right"><font color="#FF0000"> * </font> Pays: </th>
                        <td align="Left">
                            <input type="Text" name="Pays" value="<?php echo $ChampOK[10]; ?>" size="25" maxlength="50">
                        </td>
                    </tr>
                    <tr>
                        <td><br /><br />
                        </td>
                    </tr>
                    <tr>
                        <th align="Right"> Téléphone Fixe: </th>
                        <td align="Left">
                            <input type="Text" name="TelephoneFixe" value="<?php echo $ChampOK[11]; ?>" size="15" maxlength="25">
                            </font> (Format: 9 ( ) . + Espace -) </font>
                        </td>
                    </tr>
                    <tr>
                        <th align="Right"> Téléphone Mobile: </th>
                        <td align="Left">
                            <input type="Text" name="TelephoneMobile" value="<?php echo $ChampOK[12]; ?>" size="15" maxlength="25">
                            </font> (Format: 9 ( ) . + Espace -) </font>
                        </td>
                    </tr>
                    <tr>
                        <th align="Right"> Fax: </th>
                        <td align="Left">
                            <input type="Text" name="Fax" value="<?php echo $ChampOK[13]; ?>" size="15" maxlength="25">
                            </font> (Format: 9 ( ) . + Espace -) </font>
                        </td>
                    </tr>
                    <tr>
                        <td><br /><br />
                        </td>
                    </tr>
                    <tr>
                        <th align="Right"><font color="#FF0000"> * </font> Adresse Courriel: </th>
                        <td align="Left">
                            <input type="Text" name="AdresseCourrielle" value="<?php echo $ChampOK[14]; ?>" size="50" maxlength="150">
                            </font> (Format: A-Z a-z 9 . @ -) </font>
                        </td>
                    </tr>
                        <th align="Right"><font color="#FF0000"> * </font> Mot De Passe: </th>
                        <td align="Left">
                            <input type="PassWord" name="MotDePasse" value="<?php echo $ChampOK[15]; ?>" size="10" maxlength="10">
                            </font> (Format: A-Z a-z 9) </font>
                        </td>
                    </tr>
                        <th align="Right"><font color="#FF0000"> * </font> Confirmation Du Mot De Passe: </th>
                        <td align="Left">
                            <input type="PassWord" name="MotDePasse_" value="<?php echo $ChampOK[16]; ?>" size="10" maxlength="10">
                            </font> (Format: A-Z a-z 9) </font>
                        </td>
                    </tr>
                </tbody>
 
            </table>   
            <p align="Center">  
                <input class="Reset" type="Reset" value="Réinitialiser" style="color:#FF0000">
                &nbsp;&nbsp;&nbsp;
                <input class="Submit" type="Submit" 
                          name="Submit" value="Envoyer" style="color:#008000">
            </p>
        </form>
 
 
    </body>
 
</html>

Cordialement.
Trebor_ est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 08h05.


 
 
 
 
Partenaires

Hébergement Web