我一直在處理聯繫表單,該表單將輸出到將通過電子郵件發送到地址的html電子郵件。這個過程非常漂亮,但它不會將數據放入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 protected]' . ', ';
$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 protected]' . "\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輸出,並在代碼「的消息:」以前是:
<<<DATA
<strong>Name:</strong> $name <br>
<strong>Email:</strong> $email <br>
<strong>Why:</strong> $subject <br>
<strong>Comment:</strong> $comments<br>
DATA;
,然後工作,但我試圖把<<<DATA
和結尾在HTML代碼之前的DATA;
,然後它不起作用。我不是一個真正的開發者,所以我不知道從哪裏開始。我希望有人能夠指出我對此的正確方向。