Я работаю над формой контакта, которая будет выводить на электронную почту в формате html, которая будет отправлена на адрес электронной почты.Процесс работает прекрасно, но он не помещает данные в html-письмо для чтения получателем.
<?php
if(isset($_POST['submit'])) {
//create an empty errors array
$errors = array();
//our form has been submitted
if($_POST['name'] == "") {
//the name field is empty
$errors[] = "The Name field is empty.";
}
if($_POST['business'] == "") {
//the business field is empty
$errors[] = "The Business name field is empty.";
}
if($_POST['telephone'] == "") {
//the telephone number field is empty
$errors[] = "The Telephone Number field is empty.";
}
if($_POST['email'] == "") {
//the email field is empty
$errors[] = "The Email address field is empty.";
}
if($_POST['enquiry'] == "") {
//the enquiry field is empty
$errors[] = "The Enquiry field is empty.";
}
if(!stripos($_POST['email'], '@')) {
$errors[] = "The email address was not valid.";
}
if($_POST['antispam'] != 10) {
$errors[] = "You entered the wrong numerical answer for the anti-spam question.";
}
if(count($errors) == 0) {
// email settings
$to = 'email@address.com' . ', ';
$subject = 'Website Enquiry Form';
// headers
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'Return-Path: email@address.com' . "\r\n";
// form details
$name = $_POST['name'];
$business = $_POST['business'];
$telephone = $_POST['telephone'];
$email = $_POST['email'];
$type = $_POST['type'];
$enquiry = $_POST['enquiry'];
$message = '
<html>
<head>
<title>Website Enquiry Form</title>
</head>
<body>
The details from completed enquiry form on the website is: <br><br> <strong> $name </strong>from <strong> $business </strong> has filled the form out. The contact details for<strong> $name </strong> is<strong> $telephone </strong> and<strong> $email </strong> is the listed email address.<br><br> <strong> $type </strong> is the selected type of enquiry.<br><br> <strong>Comments:</strong><br> $enquiry <br><br>This is the end of the enquiry form.
</body>
</html>
';
if(mail($to, $subject, $message, $headers)) {
$success = true;
} else {
$success = false;
}
} else {
$success = false;
}
}
?>
Это PHP для формы запроса контакта.Это модификация существующей, которая была у меня ранее, но без вывода HTML, и код в «message:» имел обыкновение быть:
<<<DATA
<strong>Name:</strong> $name <br>
<strong>Email:</strong> $email <br>
<strong>Why:</strong> $subject <br>
<strong>Comment:</strong> $comments<br>
DATA;
, который работал тогда, но я попытался поместить <<<DATA
и заканчивается DATA;
непосредственно перед кодом HTML, и тогда это не сработало.Я на самом деле не разработчик, поэтому я не знаю, с чего начать.Я надеюсь, что кто-то может указать мне правильное направление в этом отношении.