I have a contact form on my website which relies on PHP to do it's job. The problem is that when you send a message written with cyrillic characters I only get a bunch of question marks.
Here's the code of that form below:
<?php header('Content-Type: text/html; charset=utf-8');
header('Content-Transfer-Encoding: 8bit');
if(isset($_POST['email'])){
$mailTo = "ameli_cakes@abv.bg";
$subject = "mail from web";
$body = "New message from web
<br><br>
FROM: ".$_POST['email']."<br>
NAME: ".$_POST['name']."<br>
SUBJECT: ".$_POST['subject']."<br>
COMMENTS: ".$_POST['message']."<br>";
$headers = "To: Ameli Cakes <".$mailTo.">\r\n";
$headers .= "From: ".$_POST['author']." <".$_POST['email'].">\r\n";
$headers .= 'Content-Type: text/HTML; charset=utf-8' . "\r\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\r\n";
//envio destinatario
$mail_success = mail($mailTo, $subject, $body, $headers);
}
?>
Keep in mind that my knowledge of PHP is very limited and I'm not the author of this piece of code.
The HTML of the page has the appropriate meta tag I believe, you can check it below:
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
The PHP file itself is encoded as utf-8 too (checked with notepad++).
Below is an example of what happens:
I sent using the form the message
This is non Cyrillic text, now follows some Cyrillic text. Поздрави другар!
And I receive
This is non Cyrillic text, now follows some Cyrillic text. Поздрави другар!!
I would truly appreciate any help you can give me in solving this, thank you very much for your time in reading this.
PS: IT'S FIXED!! check the code above to see how it finally worked.