我有這個send_mail.php文件。我試圖回顯一些插入到表單中的字段,而我無法使用回顯函數。我究竟做錯了什麼?如何在file_get_contents html模板中回顯輸入數據字段?
<?php
$date = $_POST['date'];
$full_name = $_POST['full_name'];
$biz_name = $_POST['biz_name'];
$activity = $_POST['activity'];
$afm = $_POST['afm'];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$mobile = $_POST['mobile'];
$address = $_POST['address'];
$city = $_POST['website'];
$email = $_POST['email'];
$discount = $_POST['discount'];
$payment_amount = $_POST['payment_amount'];
$seller_name = $_POST['seller_name'];
$to = $email;
$subject = "Welcome to our site!";
$htmlContent = file_get_contents("email_template.html");
// Set content-type header for sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers = "Content-type: text/html; charset=UTF-8" . "\r\n";
// Send email
if(mail($to,$subject,$htmlContent,$headers)):
$successMsg = 'Mail sending successful.';
else:
$errorMsg = 'Oops! Something went wrong.';
endif;
?>
而且我email_template.html看起來是這樣的:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Welcome to our site</title>
<head/>
<body>
<h1> Welcome <?php echo $full_name; ?> </h1>
...
</body>
</html>
我在web開發新的,所以要溫柔! :P
謝謝!這工作得很好! –