Answer the question
In order to leave comments, you need to log in
What could be the encoding problem?
Hello!
What could be the problem with the encoding in the body of the email?
The page with the form has 1251
The handler itself has 1251
But letters come in this form
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (isset($_POST['name'])) {$name = $_POST['name'];}
if (isset($_POST['phone'])) {$phone = $_POST['phone'];}
if (isset($_POST['istochnik'])) {$istochnik = $_POST['istochnik'];}
if (isset($_POST['problem_water'])) {$problem_water = $_POST['problem_water'];}
if (isset($_POST['object'])) {$object = $_POST['object'];}
if (isset($_POST['email'])) {$email = $_POST['email'];}
if (isset($_POST['region'])) {$region = $_POST['region'];}
$to = "[email protected]"; /*Укажите адрес, га который должно приходить письмо*/
$sendfrom = "[email protected]"; /*Укажите адрес, с которого будет приходить письмо, можно не настоящий, нужно для формирования заголовка письма*/
$headers = "From: " . strip_tags($sendfrom) . "\r\n";
$headers .= "Reply-To: ". strip_tags($sendfrom) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html;charset=windows-1251 \r\n";
$subject = "Заявка с сайта Агрико-Аква";
$message = "$formData
<b>Имя :</b> $name<br />
<b>Телефон:</b> $phone<br />
<b>Источник водоснабжения:</b> $istochnik<br />
<b>Проблемы с водой:</b> $problem_water<br />
<b>Объект:</b> $object<br />
<b>Регион:</b> $region<br />";
if (isset($_POST['email'])) {
$email = $_POST['email'];
$message .= "<b>Емейл :</b> $email<br />";
}
if (isset($_POST['comment'])) {
$comment = $_POST['comment'];
$message .= "<b>Сообщение :</b> $comment<br />";
}
$send = mail ($to, $subject, $message, $headers);
if ($send == 'true')
{
echo '<center>
Спасибо за заказ! Наш менеджер скоро свяжется с вами.
</center>';
}
else
{
echo '<center>
<b>Ошибка. Сообщение не отправлено!</b>
</center>';
}
} else {
http_response_code(403);
echo "Попробуйте еще раз";
}?>
Answer the question
In order to leave comments, you need to log in
Your page is in Windows-1251, and the POST came in UTF-8. Use iconv(), or better yet, switch to UTF-8.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question