Jump to content

Problem with PHP Email form and UTF-8


Grillitussa

Recommended Posts

Hi guys, i was hoping that one of you could be so kind to help me with my problem. The thing is i live in Iceland and we use characters like "æ ö þ ð á é í ó.." and so on and my PHP form does not display them correctly i can hardly read my customers requests that come from my web page. I am going to display my code in hope that there is some one out there that could help me solve this problem.

 

best regards,

Vilhjalmur.

 

here goes the code. For those of you that want to understand the icelandic words "Nafn = Name" "Netfang = Email" "Simi = Phone" "Skilabod = Messages"

 

<?php

$Nafn = $_POST['Nafn'];

$Netfang = $_POST['Netfang'];

$Simi = $_POST['Simi'];

$Skilabod = $_POST['Skilabod'];

 

 

$isl = array('á','é','ý','ú','í','ó','ö','þ','ð','æ','Á','É','Ý','Ú','Í','Ó','Ö','Þ','Ð','Æ');

$ens = array('a','e','y','u','i','o','o','th','d','ae','A','E','Y','U','I','O','O','TH','D','AE');

$skilabod = str_replace($isl,$ens,$skilabod);

 

$message = 'Nafn: ' . $Nafn .' 

Netfang: ' . $Netfang .' 

Skilabod: ' .$Skilabod .'

Simi: ' .$Simi;

 

$to = '[email protected]';

$subject = 'Fyrirspurn fra einkathjalfari.is';

 

if (!mail($to, $subject, $message)){

header('Location:gekk_ekki.html');

}

else {

header('Location:gekk.html');

}

 

?>

Link to comment
https://forums.phpfreaks.com/topic/116773-problem-with-php-email-form-and-utf-8/
Share on other sites

Look at this line:

$skilabod = str_replace($isl,$ens,$skilabod);

 

You are using lowercase 's' whereas your variable you declared earlier, which holds the actual message has an uppercase 'S'.

 

Then later on in your $message variable you use the uppercase 'S' which means that nothing would've been changed.

 

Try changing the line to this:

$Skilabod = str_replace($isl,$ens,$Skilabod);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.