This is what the message is showing: Cão açorda água côco teste acentuação
This is what I wanted it to show: Cão açorda água côco teste acentuação
Can someone give me a hand? I would be very grateful.
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if(!empty($_POST['contactname']) && !empty($_POST['contactemail']) && !empty($_POST['contactmessage'])) {
$to = 'email@gmail.com'; // Your e-mail address here.
$body = "
NCliente: {$_POST['contactname']}
Email: {$_POST['contactemail']}
{$_POST['contactmessage']}
";
mail($to, "Mensagem de ", $body, "From: {$_POST['contactemail']}"); // E-Mail subject here.
}
}
?>
This looks like an encoding problem. If you want to display characters like 'ç', typical from portuguese language, you need to decode your text parameters to the UTF-8 pattern. That way, they are going to be displayed properly.
To do that, you could try using utf8_decode(string) function from PHP. Something like this:
$contactname = utf8_decode($_POST['contactname']);
EDIT: Your code would look like this:
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if(!empty($_POST['contactname']) && !empty($_POST['contactemail']) && !empty($_POST['contactmessage'])) {
//this is the part where you convert to utf8 pattern
$namecontact = utf8_decode($_POST['contactname']);
$messagecontact = utf8_decode($_POST['contactmessage']);
$to = 'email@gmail.com'; // Your e-mail address here.
$body = "
NCliente: " .$namecontact. "
Email: {$_POST['contactemail']}
". $messagecontact ."
";
mail($to, "Mensagem de ", $body, "From:" . $namecontact); // E-Mail subject here.
}
}
?>