Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

Accent in my form mail - PHP

New Here ,
Jul 29, 2009 Jul 29, 2009

Hi,

This my problem,

I find a PHP script who let me able to create a form mail in flash. User enter informations in a flash form  and after the form communicate with this php page:

<?php

$sendTo = "need@help.com";
$subject = "Un message de votre site Web";
$headers = "From: MESSAGE <
need@help.com>\r\n";
$headers .= "Reply-To: " . $_POST["item4"] . "\r\n";
$headers .= "Return-path: " . $_POST["item4"];

$item1 = mb_convert_encoding($item1 ,"iso-8859-9","utf-8");
$item1 = $_POST["item1"];

$item3 = mb_convert_encoding($item3 ,"iso-8859-9","utf-8");
$item3 = $_POST["item3"];

$item4 = mb_convert_encoding($item4 ,"iso-8859-9","utf-8");
$item4 = $_POST["item4"];

$item6 = mb_convert_encoding($item6 ,"iso-8859-9","utf-8");
$item6 = $_POST["item6"];

$item7 = mb_convert_encoding($item7 ,"iso-8859-9","utf-8");
$item7 = $_POST["item7"];

$scevap = mb_convert_encoding($scevap, "iso-8859-9", "utf-8");
$scevap = $_POST["scevap"];

$body = "Nom ou Entreprise : $item1 \nE-mail : $item4 \nTelephone : $item3 \nRace de chien : $item6 \n\nMESSAGE : \n$item7 ";

$message =stripslashes($message);

mail($sendTo , $subject , $body , $headers);

?>

then I receive perfectly the message in my mail box but accent caracter like Ć© ' Ć  ect ... doesn't work, they are replaced by strange caracter.

Somebody have an idea of what I have to do to see accent perfectly ?

Thanks for everybody who will help me !

TOPICS
Server side applications
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 29, 2009 Jul 29, 2009

Your PHP script is attempting to convert from utf-8 encoding to iso-8859-9, but everything is the wrong way round. For example:

$item1 = mb_convert_encoding($item1 ,"iso-8859-9","utf-8");
$item1 = $_POST["item1"];

$item1 doesn't exist at the time you're trying to convert it. For it to work, the lines need to be the other way round:

$item1 = $_POST["item1"];

$item1 = mb_convert_encoding($item1 ,"iso-8859-9","utf-8");

However, it's not necessary to convert from UTF-8. Simply make the email UTF-8 encoded

...
Translate
LEGEND ,
Jul 29, 2009 Jul 29, 2009

Your PHP script is attempting to convert from utf-8 encoding to iso-8859-9, but everything is the wrong way round. For example:

$item1 = mb_convert_encoding($item1 ,"iso-8859-9","utf-8");
$item1 = $_POST["item1"];

$item1 doesn't exist at the time you're trying to convert it. For it to work, the lines need to be the other way round:

$item1 = $_POST["item1"];

$item1 = mb_convert_encoding($item1 ,"iso-8859-9","utf-8");

However, it's not necessary to convert from UTF-8. Simply make the email UTF-8 encoded. To do this, you need to add the encoding to the headers. However, your current script has a serious security flaw in it. You should never include an email address gathered from a form in the headers without first checking that it isn't attempting to inject a spam relaye into your email.

Change this section:

$headers = "From: MESSAGE <need@help.com>\r\n";
// include the email in the headers only if safe
if (!preg_match('/Content-Type:|Cc:|Bcc:/i', $_POST['item4'])) {
  $headers .= "Reply-To: " . $_POST["item4"] . "\r\n";
  $headers .= "Return-path: " . $_POST["item4"] . "\r\n";
}
// send the email as UTF-8 encoding
$headers .= 'Content-Type: text/plain; charset=utf-8';
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 29, 2009 Jul 29, 2009
LATEST

You got it !

Thanks you very much ... it's very helpfull and appreciated !

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines