IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Formulaire et encodage de carractère


Sujet :

Langage PHP

  1. #1
    Invité
    Invité(e)
    Par défaut Formulaire et encodage de carractère
    Bonjour,

    Voilà j'ai un petit soucis sur un formulaire avec des caractères mal encodés.
    Mon site est sous le charset utf-8.
    Voilà mon 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
    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
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
     
    <?php
    /***************************************************************************
     *  Fichier : /pages/Points-noirs.php
     *  Date de création : 26/12/2008
     *  Dernière modification : 26/12/2008
     ***************************************************************************/
    // Sécurité
    if ( !defined ( 'FFMC11' ) )
    {
        header ( 'Location: ../' );
        die ( -1 );
    }
    // Ne rien modifier ci-dessous!!!!!!
    $list['f_1']=array("Autoroute","Route Nationale","Route Départementale","Autre (précise)");
    $list['f_5']=array("Nids de poule","Gravillons","Dos d'âne","Ornières");
    $list['f_6']=array("Trop hauts","Trop brusques","Déformé","Mal signalés");
    $list['f_7']=array("Peu visible","Trop lisse","Trop épaisse","Trop glissante");
    $list['f_8']=array("Manquante","Endommagée","Dangeureuse","Non doublée");
    $list['f_9']=array("Non signalé","Mauvais dévers","Sans visibilité","Glissant");
    $list['f_10']=array("Sans visibilité","Mauvaise compréhension");
    $list['f_11']=array("Surélevées","Enfonées","Glissantes");
    $list['f_12']=array("Présence d'eau","Eclairage défectueux","Feux ou panneau non visibles","Travaux non signalés","Végétation débordante","Terre plein central non visible");
    if(isset($_POST['submit']))
    	{
    		$erreur="";
    		// Nettoyage des entrées
    		while(list($var,$val)=each($_POST))
    			{
    				if(!is_array($val))
    				{
    					$$var=strip_tags($val);
    				}
    				else
    				{
    					while(list($arvar,$arval)=each($val))
    					{
    						$$var[$arvar]=strip_tags($arval);
    					}
    				}
    			}
    	// Formatage des entrées
    	// Verification des champs
    	if(!$f_1)
    	{
    		$erreur.="<li><span class='txterror'>Le champ &laquo; Situation &raquo; requiert au moins une sélection.</span>";
    		$errf_1=1;
    	}
    	if(strlen($f_14)<2)
    	{
    		$erreur.="<li><span class='txterror'>Le champ &laquo; Tes coordonnées : (nom, prénom, adresse complète, téléphone,E-mail) &raquo; est vide ou incomplet.</span>";
    		$errf_14=1;
    	}
    	if($erreur=="")
    	{
    		// Création du message
    		$titre="Vous avez reçu une fiche signalitique \"POINT NOIR\"";
    		$tete ="From:xxxx@free.fr"."\n";
    		for($id=0; $id<count($list['f_1']); $id++)
    		{
    			if($f_1[$id]==1)
    			{
    				$corps.="Situation : ".$list['f_1'][$id]."\n\n";
    			}
    		}
    		$corps.="Route N° ou nom (Av,Bd,Rue...) : ".$f_2."\n\n";
    		$corps.="De : ".$f_3."\n";
    		$corps.="Vers : ".$f_4."\n";
    		for($id=0; $id<count($list['f_5']); $id++)
    		{
    			if($f_5[$id]==1)
    			{
    				$corps.="Etat de la Route : ".$list['f_5'][$id]."\n\n";
    			}
    		}
    		for($id=0; $id<count($list['f_6']); $id++)
    		{
    			if($f_6[$id]==1)
    			{
    				$corps.="Ralentisseurs : ".$list['f_6'][$id]."\n\n";
    			}
    		}
    		for($id=0; $id<count($list['f_7']); $id++)
    		{
    			if($f_7[$id]==1)
    			{
    				$corps.="Peinture : ".$list['f_7'][$id]."\n\n";
    			}
    		}
    		for($id=0; $id<count($list['f_8']); $id++)
    		{
    			if($f_8[$id]==1)
    			{
    				$corps.="Glissière de sécurité : ".$list['f_8'][$id]."\n\n";
    			}
    		}
    		for($id=0; $id<count($list['f_9']); $id++)
    		{
    			if($f_9[$id]==1)
    			{
    				$corps.="Virage : ".$list['f_9'][$id]."\n\n";
    			}
    		}
    		for($id=0; $id<count($list['f_10']); $id++)
    		{
    			if($f_10[$id]==1)
    			{
    				$corps.="Carrefour : ".$list['f_10'][$id]."\n\n";
    			}
    		}
    		for($id=0; $id<count($list['f_11']); $id++)
    		{
    			if($f_11[$id]==1)
    			{
    				$corps.="Plaques d'égouts : ".$list['f_11'][$id]."\n\n";
    			}
    		}
    		for($id=0; $id<count($list['f_12']); $id++)
    		{
    			if($f_12[$id]==1)
    			{
    				$corps.="Ou : ".$list['f_12'][$id]."\n\n";
    			}
    		}
    		$corps.="Autres observations : ".$f_13."\n";
    		$corps.="Tes coordonnées (nom, prénom, adresse complète, téléphone,E-mail) : ".$f_14."\n\n";
    		if(mail("xxxxx@live.fr", $titre, stripslashes($corps), $tete))
    		{
    			$ok_mail="true";
    		}
    		else
    		{
    			$erreur.="<li><span style=\"color:#C00; font-size:16px; font-weight:bold\">Une erreur est survenue lors de l'envoi du message, veuillez refaire une tentative.</span>";
    		}
    	}
    }
     
    if($ok_mail=="true")
    { 
     
    	$page_texte .="<table width='100%' border='1' cellspacing='1' cellpadding='1'>
    		<tr>
                <td align='center'>
                    <span style=\"color:#C00; font-weight:bold;\">La fiche signalitique nous a bien été transmise, et nous vous en remercions.</span>
                </td>
            </tr>
    		<tr>
                <td align='center'>
                    <span style=\"color:#000; font-weight:bold;\">Nous allons y donner suite dans les meilleurs délais.<br>A bientôt.<br><br><a href='index.php?page=Accueil'>Retour à l'accueil</a></span>
                </td>
            </tr>
    	</table>";
    }
    else
    {
    $page_texte .="
    <table border=\"0\" align=\"center\" width=\"90%\">
        <tr>
            <td>
            	<h3>Fiche signalitique \"POINTS NOIRS\"</h3>
            </td>
        </tr>
        <tr>
            <td align=\"justify\">
            	Les \"Monsieurs MOTO\" ne peuvent pas connaître toutes les routes de leur département. Ils ont besoin de chacun d'entre nous pour leur signaler tous les défauts que nous rencontrons sur les routes. Remplis le formulaire ci-dessous pour que nous puissions le transmettre à Monsieur MOTO.<br />N'oublie surtout pas tes cooordonnées car parfois les DDE ont besoin de plus d'infos.
            </td>
    	<tr>
    	</tr>
    		<td align=\"center\">
    			<b><i>Soit le plus précis possible.</i></b><br>Merci.
    		</td>
        </tr>
    </table>
    ";
    $page_texte .="
    <form action='index.php?page=Points-noirs' method='post' name='Form'>
    <table width='90%' border='1' bordercolor='#009900' cellspacing='10' cellpadding='5'>";
    if($erreur)
    { 
        $page_texte .="<tr>
            <td colspan='2' align='center'>
    			<span style=\"color:#F00; font-size:18px; font-weight:bold;\">
    				<b>&nbsp;ERREUR, votre message n'a pas été transmis ! Vérifiez que les champs obligatoires sont remplis !</b>
    			</span>
            </td>
        </tr>";
    }
        $page_texte .="
    	<tr>
            <td colspan='2' align='center'>
                <span style=\"color:#C00; font-size:18px; font-weight:bold;\">Les champs marqué d'un * sont obligatoires.</span>
            </td>
        </tr>
        <tr>
            <td align='right' valign='top' width='30%'>
                <span class='txtform'>
                    <b>Situation<span style=\"color:#C00; font-size:18px; font-weight:bold;\">*</span> :</b>
                </span>
            </td>
        	<td>
                <table border='0' cellspacing='0' cellpadding='0'>";
                for($id=0;$id<count($list['f_1']);$id++)
                {
                if($f_1[$id]==1)
                    {
                    $ct="checked";
                    }
    				  $page_texte .="
    				  <tr>
    					  <td>
    						  <input ".$ct." type=\"checkbox\" name=\"f_1[$id]\" value=\"1\" border=\"0\"> - <span class='txtform'>".$list[f_1][$id]."</span>
    					  </td>
    				  </tr>";
                unset($ct);
                }
                $page_texte .="</table>
    		</td>
    	</tr>
        <tr>
            <td align='right' valign='top' width='30%'>
                <span class='txtform'>
                    <b>Route N° ou nom (Av,Bd,Rue...) :</b>
                </span>
            </td>
            <td>";
    			$page_texte .="<textarea style='width:360"; 
    			if($errf_2==1)
    				{
    					$page_texte .="ERREUR";
    				}
    				$page_texte .="' name='f_2' rows='5' cols='20'>";
    				echo $f_2;
    			$page_texte .="</textarea>
            </td>
        </tr>
        <tr>
            <td align='right' valign='top' width='30%'>
                <span class='txtform'>
                    <b>De :</b>
                </span>
            </td>
            <td>";
                $page_texte .="
    			<textarea style='width:360"; 
    			if($errf_3==1)
    				{
    					$page_texte .="ERREUR";
    				}
    				$page_texte .=";' name='f_3' rows='5' cols='20'>";
    				echo $f_3;
                $page_texte .="
    			</textarea>
            </td>
        </tr>
        <tr>
            <td align='right' valign='top' width='30%'>
                <span class='txtform'>
                    <b>Vers :</b>
                </span>
            </td>
            <td>";
                $page_texte .="
    			<textarea style='width:360"; 
    			if($errf_4==1)
    				{
    					$page_texte .="ERREUR";
    				};
    				$page_texte .="' name='f_4' rows='5' cols='20'>";
    				echo $f_4;
                $page_texte .="
    			</textarea>
            </td>
        </tr>
        <tr>
            <td align='right' valign='top' width='30%'>
                <span class='txtform'>
                    <b>Etat de la Route :</b>
                </span>
            </td>
            <td>
                <table border='0' cellspacing='0' cellpadding='0'>";
                    for($id=0;$id<count($list['f_5']);$id++)
                    {
                    if($f_5[$id]==1)
                        {
                        $ct="checked";
                        }
    					  $page_texte .="
    					  <tr>
    						  <td>
    							  <input ".$ct." type='checkbox' name='f_5[$id]' value='1' border='0'> - <span class='txtform'>".$list[f_5][$id]."</span>
    						  </td>
    					  </tr>";
                    unset($ct);
                    }
                $page_texte .="</table>
            </td>
        </tr>
        <tr>
            <td align='right' valign='top' width='30%'>
                <span class='txtform'>
                    <b>Ralentisseurs :</b>
                </span>
            </td>
            <td>
                <table border='0' cellspacing='0' cellpadding='0'>";
                    for($id=0;$id<count($list['f_6']);$id++)
                    {
                    if($f_6[$id]==1)
                        {
                        $ct="checked";
                        }
    					  $page_texte .="
    					  <tr>
    						  <td>
    							  <input ".$ct." type='checkbox' name='f_6[$id]' value='1' border='0'> - <span class='txtform'>".$list[f_6][$id]."</span>
    						  </td>
    					  </tr>";
                    unset($ct);
                    }
                $page_texte .="</table>
            </td>
        </tr>
        <tr>
            <td align='right' valign='top' width='30%'>
                <span class='txtform'>
                    <b>Peinture :</b>
                </span>
            </td>
            <td>
                <table border='0' cellspacing='0' cellpadding='0'>";
                    for($id=0;$id<count($list['f_7']);$id++)
                    {
                    if($f_7[$id]==1)
                        {
                        $ct="checked";
                        }
    					  $page_texte .="
    					  <tr>
    						  <td>
    							  <input ".$ct." type='checkbox' name='f_7[$id]' value='1' border='0'> - <span class='txtform'>".$list[f_7][$id]."</span>
    						  </td>
    					  </tr>";
                    unset($ct);
                    }
                $page_texte .="</table>
            </td>
        </tr>
        <tr>
            <td align='right' valign='top' width='30%'>
                <span class='txtform'>
                    <b>Glissière de sécurité :</b>
                </span>
            </td>
            <td>
                <table border='0' cellspacing='0' cellpadding='0'>";
                    for($id=0;$id<count($list['f_8']);$id++)
                    {
                    if($f_8[$id]==1)
                        {
                        $ct="checked";
                        }
    					  $page_texte .="
    					  <tr>
    						  <td>
    							  <input ".$ct." type='checkbox' name='f_8[$id]' value='1' border='0'> - <span class='txtform'>".$list[f_8][$id]."</span>
    						  </td>
    					  </tr>";
                    unset($ct);
                    }
                $page_texte .="</table>
            </td>
        </tr>
        <tr>
            <td align='right' valign='top' width='30%'>
                <span class='txtform'>
                    <b>Virage :</b>
                </span>
            </td>
            <td>
                <table border='0' cellspacing='0' cellpadding='0'>";
                    for($id=0;$id<count($list['f_9']);$id++){
                    if($f_9[$id]==1)
                        {
                        $ct="checked";
                        }
    					  $page_texte .="
    					  <tr>
    						  <td>
    							  <input ".$ct." type='checkbox' name='f_9[$id]' value='1' border='0'> - <span class='txtform'>".$list[f_9][$id]."</span>
    						  </td>
    					  </tr>";
                    unset($ct);
                    }
                $page_texte .="</table>
            </td>
        </tr>
        <tr>
            <td align='right' valign='top' width='30%'>
                <span class='txtform'>
                    <b>Carrefour :</b>
                </span>
            </td>
            <td>
                <table border='0' cellspacing='0' cellpadding='0'>";
                    for($id=0;$id<count($list['f_10']);$id++){
                    if($f_10[$id]==1)
                        {
                        $ct="checked";
                        }
    					  $page_texte .="
    					  <tr>
    						  <td>
    							  <input ".$ct." type='checkbox' name='f_10[$id]' value='1' border='0'> - <span class='txtform'>".$list[f_10][$id]."</span>
    						  </td>
    					  </tr>";
                    unset($ct);
                    }
                $page_texte .="</table>
            </td>
        </tr>
        <tr>
            <td align='right' valign='top' width='30%'>
                <span class='txtform'>
                    <b>Plaques d'égouts :</b>
                </span>
            </td>
            <td>
                <table border='0' cellspacing='0' cellpadding='0'>";
                    for($id=0;$id<count($list['f_11']);$id++)
                    {
                    if($f_11[$id]==1)
                        {
                        $ct="checked";
                        }
    					  $page_texte .="
    					  <tr>
    						  <td>
    							  <input ".$ct." type='checkbox' name='f_11[$id]' value='1' border='0'> - <span class='txtform'>".$list[f_11][$id]."</span>
    						  </td>
    					  </tr>";
                    unset($ct);
                    }
                $page_texte .="</table>
            </td>
        </tr>
        <tr>
            <td align='right' valign='top' width='30%'>
                <span class='txtform'>
                    <b>Ou :</b>
                </span>
            </td>
            <td>
                <table border='0' cellspacing='0' cellpadding='0'>";
                    for($id=0;$id<count($list['f_12']);$id++)
                    {
                    if($f_12[$id]==1)
                        {
                        $ct="checked";
                        }
    					  $page_texte .="
    					  <tr>
    						  <td>
    							  <input ".$ct." type='checkbox' name='f_12[$id]' value='1' border='0'> - <span class='txtform'>".$list[f_12][$id]."</span>
    						  </td>
    					  </tr>";
                    unset($ct);
                    }
                $page_texte .="</table>
            </td>
        </tr>
        <tr>
            <td align='right' valign='top' width='30%'>
                <span class='txtform'>
                    <b>Autres observations :</b>
                </span>
            </td>
            <td>";
                $page_texte .="<textarea style='width:360"; 
    			if($errf_13==1)
    				{
    					$page_texte .="ERREUR";
    				};
    				$page_texte .="' name='f_13' rows='5' cols='20'>";
    				echo $f_13;
                $page_texte .="</textarea>
            </td>
        </tr>
        <tr>
            <td align='right' valign='top' width='30%'>
                <span class='txtform'>
                    <b>Tes coordonnées (nom, prénom, adresse complète, téléphone,E-mail)<span style=\"color:#C00; font-size:18px; font-weight:bold;\">*</span> :</b>
                </span>
            </td>
            <td>";
                $page_texte .="<textarea style='width:360"; 
    			if($errf_14==1)
    				{
    					$page_texte .="ERREUR";
    				};
    			$page_texte .="' name='f_14' rows='5' cols='20'>";
    			echo $f_14;
    			$page_texte .="</textarea>
            </td>
        </tr>
        <tr>
            <td align='right' valign='top' width='30%'>
            </td>
            <td>
                <input type='submit' name='submit' value='Envoyer la fiche !!' border='0'>
            </td>
        </tr>
    </table>
    </form>";
    } 
    ?>
    Merci beaucoup
    Dernière modification par sabotage ; 13/05/2009 à 12h28. Motif: retrait des emails

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Qu'est ce qui est mal encodé et comment cela est-il restitué ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Invité
    Invité(e)
    Par défaut
    RE

    désolé effectivement j'aurais du préciser !

    A la réception du mail les é à è etc.... apparaissent avec des carractères bizarre du style A@ !

    Merci

  4. #4
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Tu devrais specifier le charset dans le mail :
    http://a-pellegrini.developpez.com/tutoriels/php/mail/
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 3
    Dernier message: 16/09/2011, 16h09
  2. [XL-2007] Création d'un formulaire pour encodage de paiements
    Par Kikabooo dans le forum Macros et VBA Excel
    Réponses: 0
    Dernier message: 11/01/2010, 13h18
  3. Formulaire et encodage
    Par nazoreen dans le forum Langage
    Réponses: 6
    Dernier message: 24/12/2008, 15h50
  4. problème encodage avec formulaire ajax
    Par gyome314 dans le forum Ruby on Rails
    Réponses: 2
    Dernier message: 21/06/2007, 14h14
  5. Probleme d'encodage du formulaire
    Par qdqdfqfdqdxcwcrzsdfw dans le forum Struts 1
    Réponses: 1
    Dernier message: 09/05/2007, 17h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo