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 :

Mauvaise transcription des apostrophes dans le corps du mail posté via un formulaire en php


Sujet :

Langage PHP

  1. #1
    Futur Membre du Club
    Homme Profil pro
    graphiste
    Inscrit en
    Juillet 2013
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : graphiste
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Juillet 2013
    Messages : 4
    Points : 6
    Points
    6
    Par défaut Mauvaise transcription des apostrophes dans le corps du mail posté via un formulaire en php
    Bonjour,
    je viens de terminer un formulaire en méthode post pour mon site, je dois le mettre en ligne rapidement.
    Lors des tests d'envoi, je me heurte à une mauvaise transcription des apostrophes, exemple :
    "l'abeille" devient "l/'abeille" dans le corps du mail.

    Je vous remercie à l'avance de vos solutions éclairées.
    Bien cordialement.

    Je vous copie le code exemple :

    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
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <?php
     
    // On vérifie si la fonction ini_set() a été désactivée...
    $desactive = ini_get('disable_functions');
    if (preg_match("/ini_set/i", "$desactive") == 0) {
     
    // Si elle n'est pas désactivée, on définit ini_set de manière à*n'afficher que les erreurs...
    ini_set("error_reporting" , "E_ALL & ~E_NOTICE");
    }
     
    // Vérifier que le formulaire a été envoyé...
    if (isset($_POST['envoi'])) {
     
    // On commence une session pour enregistrer les variables du formulaire...
    session_start();
     
    $_SESSION['champ1'] = $_POST['champ1'];
    $_SESSION['champ2'] = $_POST['champ2'];
    $_SESSION['champ3'] = $_POST['champ3'];
    $_SESSION['champ4'] = $_POST['champ4'];
    $_SESSION['champ5'] = $_POST['champ5'];
    $_SESSION['champ6'] = $_POST['champ6'];
    $_SESSION['champ7'] = $_POST['champ7'];
    $_SESSION['champ8'] = $_POST['champ8'];
    $_SESSION['champ9'] = $_POST['champ9'];
    $_SESSION['champ10'] = $_POST['champ10'];
    $_SESSION['zone_email1'] = $_POST['zone_email1'];
     
    //Enregistrement des zones de texte...
    $_SESSION['zone_texte1'] = $_POST['zone_texte1'];
     
    // Définir l'icone apparaissant en cas d'erreur...
     
    // Définir sur 0 pour afficher un petit x de couleur rouge.
    // Définir sur 1 pour afficher l'image d'une croix rouge telle que celle utilisée dans l'assistant
    // Si on utilise l'option 1, l'image de la croix rouge 'icone.gif' doit se trouver dans le répertoire 'images',
    // ce dernier devant se trouver au même niveau que le formulaire...
    $flag_icone = 0;
     
    // On vérifie si $flag_icone est défini sur 0 ou 1...
    if ($flag_icone == 0) {
    $icone = "<b><font size=\"3\" face=\"Arial\" color=\"#CC0000\">x</font></b>";
    } else {
    $icone = "<img src=\"images/icone.gif\"";
    }
     
    // Définir l'indicateur d'erreur sur zéro...
    $flag_erreur = 0;
     
    // N'envoyer le formulaire que s'il n'y a pas d'erreurs...
    if ($flag_erreur == 0) {					
     
    // Adresse de réception du formulaire
    $email_dest = "mail@mail.fr";
    $sujet = "Demande";
    $entetes ="MIME-Version: 1.0 \n";
    	$entetes .="From: MOI<mail@mail.fr>\n";
    	$entetes .="Return-Path: MOI <mail@mail.fr>\n";
    	$entetes .="Reply-To: MOI <mail@mail.fr>\n";
    	$entetes .="Content-Type: text/html; charset=iso-8859-1 \n";
    	$partie_entete = "<html>\n<head>\n<title>Formulaire</title>\n<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>\n</head>\n<body bgcolor=#FFFFFF>\n";
     
    //Partie HTML de l'e-mail... 1ère ligne grosseur et couleur du texte
    $partie_champs_texte .= "<font face='Arial' size='4' color='#000000'>Nom = " . $_SESSION['champ1'] . "</font><br>\n";
    $partie_champs_texte .= "<font face=\"Arial\" size=\"4\" color=\"#000000\">Pr&eacute;nom = " . $_SESSION['champ2'] . "</font><br>\n";
    $partie_champs_texte .= "<font face=\"Arial\" size=\"4\" color=\"#000000\">Soci&eacute;t&eacute; = " . $_SESSION['champ3'] . "</font><br>\n";
    $partie_champs_texte .= "<font face=\"Arial\" size=\"4\" color=\"#000000\">Pseudo = " . $_SESSION['champ4'] . "</font><br>\n";
    $partie_champs_texte .= "<font face=\"Arial\" size=\"4\" color=\"#000000\">Adresse = " . $_SESSION['champ5'] . "</font><br>\n";
    $partie_champs_texte .= "<font face=\"Arial\" size=\"4\" color=\"#000000\">Code postal = " . $_SESSION['champ6'] . "</font><br>\n";
    $partie_champs_texte .= "<font face=\"Arial\" size=\"4\" color=\"#000000\">Ville = " . $_SESSION['champ7'] . "</font><br>\n";
    $partie_champs_texte .= "<font face=\"Arial\" size=\"4\" color=\"#000000\">T&eacute;l&eacute;phone = " . $_SESSION['champ8'] . "</font><br>\n";
    $partie_champs_texte .= "<font face=\"Arial\" size=\"4\" color=\"#000000\">Fax = " . $_SESSION['champ9'] . "</font><br>\n";
    $partie_champs_texte .= "<font face=\"Arial\" size=\"4\" color=\"#000000\">Portable = " . $_SESSION['champ10'] . "</font><br>\n";
    $partie_zone_email .= "<font face=\"Arial\" size=\"4\" color=\"#000000\">E-mail = " . $_SESSION['zone_email1'] . "</font><br>\n";
    $partie_zone_texte .= "<font face=\"Arial\" size=\"4\" color=\"#000000\">Votre demande = " . $_SESSION['zone_texte1'] . "</font><br>\n";
     
    // Fin du message HTML
    $fin = "</body></html>\n\n";
    $sortie = $partie_entete . $partie_champs_texte . $partie_zone_email . $partie_listes . $partie_boutons . $partie_cases . $partie_zone_texte . $fin;
     
    // Send the e-mail
    if (@!mail($email_dest,$sujet,$sortie,$entetes)) {
    echo("Envoi du formulaire impossible");
    exit();
    } else {
     
    // Rediriger vers la page de remerciement
    header("Location:accuse.html");
    exit();
    } // Fin else
    } // Fin du if ($flag_erreur == 0) {
    } // Fin de if POST
    ?>
     
    <html xmlns="http://www.w3.org/1999/xhtml"/>
    <head>
     
    <title> FORMULAIRE </title>
     
    <script language="JavaScript">
     
    function verifSelection() {
     
    if (document.mail_form.champ1.value == "") {
    alert("Veuillez indiquer votre Nom s'il vous plaît !")
    return false
    } 
     
    if (document.mail_form.champ4.value == "") {
    alert("Veuillez indiquer votre Pseudo s'il vous plaît !")
    return false
    } 
     
    if (document.mail_form.champ6.value == "") {
    alert("Veuillez indiquer votre Code Postal s'il vous plaît !")
    return false
    } 
     
    if (document.mail_form.champ7.value == "") {
    alert("Veuillez indiquer votre Ville s'il vous plaît !")
    return false
    } 
     
    if (document.mail_form.zone_email1.value == "") {
    alert("Veuillez indiquer votre Adresse E-mail s'il vous plaît !")
    return false
    }
     
    invalidChars = " /:,;'"
     
    for (i=0; i < invalidChars.length; i++) {	// does it contain any invalid characters?
    badChar = invalidChars.charAt(i)
     
    if (document.mail_form.zone_email1.value.indexOf(badChar,0) > -1) {
    alert("Votre adresse e-mail contient des caractères invalides. Veuillez vérifier.")
    document.mail_form.zone_email1.focus()
    return false
    }
    }
     
    atPos = document.mail_form.zone_email1.value.indexOf("@",1)			// there must be one "@" symbol
    if (atPos == -1) {
    alert('Votre adresse e-mail ne contient pas le signe "@". Veuillez vérifier.')
    document.mail_form.zone_email1.focus()
    return false
    }
     
    if (document.mail_form.zone_email1.value.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
    alert('Il ne doit y avoir qu'un signe "@". Veuillez vérifier.')
    document.mail_form.zone_email1.focus()
    return false
    }
     
    periodPos = document.mail_form.zone_email1.value.indexOf(".",atPos)
     
    if (periodPos == -1) {					// and at least one "." after the "@"
    alert('Vous avez oublié le point "." après le signe "@". Veuillez vérifier.')
    document.mail_form.zone_email1.focus()
    return false
    }
     
    if (periodPos+3 > document.mail_form.zone_email1.value.length)	{		// must be at least 2 characters after the 
    alert('Il doit y avoir au moins deux caractères après le signe ".". Veuillez vérifier.')
    document.mail_form.zone_email1.focus()
    return false
    }
     
    if (document.mail_form.zone_texte1.value == "") {
    alert("Veuillez formuler votre Demande s'il vous plaît !")
    return false
    }
     
    } // Fin de la fonction
    </script>
     
    <link href="style/style.css" rel="stylesheet" type="text/css" />
     
    <style type="text/css">
     
    </head>
     
    <BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
     
    <form name="mail_form" method="post" action="<?=$_SERVER['../website/PHP_SELF']?>" onSubmit="return verifSelection()">
     
    <?php
    if ($erreur_champ1) {echo(stripslashes($erreur_champ1));
    } else {
    if ($erreur_champ2) {echo(stripslashes($erreur_champ2));
    } else {
    if ($erreur_champ3) {echo(stripslashes($erreur_champ3));
    } else {
    if ($erreur_champ4) {echo(stripslashes($erreur_champ4));
    } else {
    if ($erreur_champ5) {echo(stripslashes($erreur_champ5));
    } else {
    if ($erreur_champ6) {echo(stripslashes($erreur_champ6));
    } else {
    if ($erreur_champ7) {echo(stripslashes($erreur_champ7));
    } else {
    if ($erreur_champ8) {echo(stripslashes($erreur_champ8));
    } else {
    if ($erreur_champ9) {echo(stripslashes($erreur_champ9));
    } else {
    if ($erreur_champ10) {echo(stripslashes($erreur_champ10));
    } else {
    if ($erreur_email1) {echo(stripslashes($erreur_email1));
    } else {
    if ($erreur_texte1) {echo(stripslashes($erreur_texte1));
    } else {
    } // Fin du else...
    } // Fin du else...
    } // Fin du else...
    } // Fin du else...
    } // Fin du else...
    } // Fin du else...
    } // Fin du else...
    } // Fin du else...
    } // Fin du else...
    } // Fin du else...
    } // Fin du else...
    } // Fin du else...
    ?>
     
    	<table width="649" border="0" cellspacing="0" cellpadding="0">
    		<tr height="24">
    			<td align="left" valign="top" bgcolor="#000000" width="1" height="24"><img src="images/10px.gif" width="1" height="24" alt="" align="top"></td>
    			<td align="left" valign="top" bgcolor="white" width="30" height="24"></td>
    			<td align="left" valign="top" width="588" height="24">
    				<table width="588" border="0" cellspacing="0" cellpadding="0" bgcolor="white" height="24">
    		  			<tr height="24">
    						<td align="left" valign="middle" bgcolor="white" width="7" height="24"><img src="images/carre_h5.gif" width="7" height="7" alt="" align="middle"></td>
    						<td align="left" valign="middle" bgcolor="white" width="7" height="24"><img src="images/10px.gif" width="7" height="7" alt="" align="middle"></td>
    						<td height="24" align="left" valign="middle" bgcolor="white" class="class">Formulaire de contact</td>
    						<td align="left" valign="middle" bgcolor="white" width="355" height="24" background="images/fil_vert.gif"></td>
    			  		</tr>
    			  </table>
    	  		</td>
    			<td align="left" valign="top" width="30" height="24" background="images/fil_vert.gif"></td>
    		</tr>
    		<tr>
    			<td align="left" valign="top" bgcolor="#000000" width="1" height="31"><img src="images/10px.gif" width="1" height="31" align="top"></td>
    			<td align="left" valign="top" width="30" height="400"></td>
    			<td width="588" height="400" align="center" valign="middle">
            		<table width="588" border="0" align="left" valign="middle" cellpadding="0" cellspacing="0">
       			  <tr>
       			    <td width="388" height="30" align="right" valign="middle"></td>
       			    <td width="10" height="30" align="left" valign="middle"><img src="images/10px.gif" width="10" height="30" alt="" align="middle"></td>
       			    <td width="190" height="30" align="left" valign="middle" class="class">
       			  </tr>
       			  <tr>
           			<td width="388" align="right" valign="middle"><input name="champ1" type="text" value="<?=stripslashes($_SESSION['champ1']);?>"></td>
    <td width="10" align="left" valign="middle">
    						<?php
    						if ($erreur_champ1) {echo($icone);}
    						?></td>
           			  <td width="190" align="left" valign="middle" class="class">Nom <span class="class">*</span></tr>
              			<tr>
               			  <td width="388" align="right" valign="middle"><input name="champ2" type="text" value="<?=stripslashes($_SESSION['champ2']);?>"></td>
               			  <td width="10" align="left" valign="middle">
    						<?php
    						if ($erreur_champ2) {echo($icone);}
    						?></td>
                			<td width="190" align="left" valign="middle" class="class">Pr&eacute;nom</td>
           			  </tr>
              			<tr>
               			  <td width="388" align="right" valign="middle"><input name="champ3" type="text" value="<?=stripslashes($_SESSION['champ3']);?>"></td>
               			  <td width="10" align="left" valign="middle">
    						<?php
                            if ($erreur_champ3) {echo($icone);}
    						?></td>
                			<td width="190" align="left" valign="middle" class="class">Soci&eacute;t&eacute;</td>
           			  </tr>
              			<tr>
               			  <td width="388" align="right" valign="middle"><input name="champ4" type="text" value="<?=stripslashes($_SESSION['champ4']);?>"></td>
               			  <td width="10" align="left" valign="middle">
    						<?php
    						if ($erreur_champ4) {echo($icone);}
    						?></td>
                			<td width="190" align="left" valign="middle" class="class">Pseudo <span class="class">*</span></td>
           			  </tr>
              			<tr>
               			  <td width="388" align="right" valign="middle"><input name="champ5" type="text" value="<?=stripslashes($_SESSION['champ5']);?>"></td>
               			  <td width="10" align="left" valign="middle">
    						<?php
    						if ($erreur_champ5) {echo($icone);}
    						?></td>
                			<td width="190" align="left" valign="middle" class="class">Adresse</td>
           			  </tr>
              			<tr>
               			  <td width="388" align="right" valign="middle"><input name="champ6" type="text" value="<?=stripslashes($_SESSION['champ6']);?>"></td>
               			  <td width="10" align="left" valign="middle">
    						<?php
    						if ($erreur_champ6) {echo($icone);}
    						?></td>
                			<td width="190" align="left" valign="middle" class="class">Code Postal <span class="class">*</span></td>
           			  </tr>
              			<tr>
               			  <td width="388" align="right" valign="middle"><input name="champ7" type="text" value="<?=stripslashes($_SESSION['champ7']);?>"></td>
               			  <td width="10" align="left" valign="middle">
    						<?php
    						if ($erreur_champ7) {echo($icone);}
    						?></td>
               				 <td width="190" align="left" valign="middle" class="class">Ville <span class="class">*</span></td>
           			  </tr>
              			<tr>
               			  <td width="388" align="right" valign="middle"><input name="champ8" type="text" value="<?=stripslashes($_SESSION['champ8']);?>"></td>
               			  <td width="10" align="left" valign="middle">
    						<?php
    						if ($erreur_champ8) {echo($icone);}
    						?></td>
               				 <td width="190" align="left" valign="middle" class="class">T&eacute;l&eacute;phone</td>
           			  </tr>
              			<tr>
               			  <td width="388" align="right" valign="middle"><input name="champ9" type="text" value="<?=stripslashes($_SESSION['champ9']);?>"></td>
               			  <td width="10" align="left" valign="middle">
    						<?php
    						if ($erreur_champ9) {echo($icone);}
    						?></td>
                			<td width="190" align="left" valign="middle" class="class">Fax</td>
           			  </tr>
              			<tr>
               			  <td width="388" align="right" valign="middle"><input name="champ10" type="text" value="<?=stripslashes($_SESSION['champ10']);?>"></td>
               			  <td width="10" align="left" valign="middle">
    						<?php
    						if ($erreur_champ10) {echo($icone);}
    						?></td>
               				 <td width="190" align="left" valign="middle" class="class">Portable</td>
           			  </tr>
              			<tr>
               			  <td width="388" align="right" valign="middle"><input name="zone_email1" type="text" value="<?=stripslashes($_SESSION['zone_email1']);?>"></td>
      					  <td width="10" align="left" valign="middle">
    						<?php
    						if ($erreur_email1) {echo($icone);}
    						?></td>
                			<td width="190" align="left" valign="middle" class="class">Email <span class="class">*</span></td>
           			  </tr>
              			<tr>
               			  <td width="388" align="right" valign="middle"><textarea name="zone_texte1" cols="40" rows="4"><?=stripslashes($_SESSION['zone_texte1']);?></textarea></td>
    					  <td width="10" align="left" valign="middle">
    						<?php
    						if ($erreur_texte1) {echo($icone);}
    						?></td>
                			<td width="190" align="left" valign="top" class="class">Votre demande <span class="class">*<br>
                			</span></td>
           			  </tr>
              			<tr>
                			<td width="388" height="10" align="right" valign="middle"></td>
               			  <td width="10" height="10" align="left" valign="middle"><img src="images/10px.gif" width="10" height="10" alt="" align="middle"></td>
                			<td width="190" height="10" align="left" valign="middle" class="obligatoire"></td>
           			  </tr>
              			<tr>
               			  <td width="388" align="right" valign="middle"><input type="reset" name="Reset" value=" Effacer "><input type="submit" name="envoi" value="Envoyer"></td>
               			  <td width="10" align="left" valign="middle"></td>
                			<td width="190" align="left" valign="middle" class="class">* Champs obligatoires</td>
           			  </tr>
           		  </table>
    		  </td>
    	  		<td align="left" valign="top" width="30" height="400"></td>
    		</tr>
    		<tr>
      </table>
    <input name="nbre_fichiers" type="hidden" id="nbre_fichiers" value=""></form>
    </body>
    </html>

  2. #2
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2011
    Messages
    48
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2011
    Messages : 48
    Points : 47
    Points
    47
    Par défaut
    c'est assez baroque, essaie de mettre
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    foreach($_POST as $k=>$v) $_POST[$k]=stripslashes($v);
    au début

  3. #3
    Modératrice
    Avatar de Celira
    Femme Profil pro
    Développeuse PHP/Java
    Inscrit en
    Avril 2007
    Messages
    8 633
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Développeuse PHP/Java
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2007
    Messages : 8 633
    Points : 16 372
    Points
    16 372
    Par défaut
    Commence par vérifier que les magic quotes sont bien désactivées...
    Désactiver les guillemets magiques

Discussions similaires

  1. [XL-2007] Envoyer un mail avec outlook à partir d'excel avec des tableaux dans le corps du mail
    Par BarneyYagami dans le forum Macros et VBA Excel
    Réponses: 5
    Dernier message: 15/11/2014, 16h48
  2. affichage des images dans le corps d'un mail
    Par pigeon11 dans le forum VB 6 et antérieur
    Réponses: 0
    Dernier message: 24/06/2008, 13h40
  3. Réponses: 1
    Dernier message: 04/04/2008, 22h51
  4. probleme des apostrophes (') dans les requetes!
    Par le_style dans le forum JDBC
    Réponses: 12
    Dernier message: 20/06/2007, 11h40
  5. Insertion des apostrophes dans Postgres.
    Par jarod_ab dans le forum PostgreSQL
    Réponses: 5
    Dernier message: 13/02/2006, 11h37

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