我有一個HTML-PHP混合的聯繫表單。PHP表單不會將提交的數據發送到電子郵件
PHP腳本旨在將表單數據發送到電子郵件地址,但它僅發送元素標識並且不附加提交的值。
下面是我使用的代碼:
<?php
$ToEmail = '[email protected]';
$EmailSubject = 'Site contact form';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."";
$MESSAGE_BODY .= "Subject: ".$_POST["subject"]."";
$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
<form class="form-horizontal" name="contactform" action="contact.php" method="post">
<div class="control-group">
<label class="control-label" for="name">Name*</label>
<div class="controls">
<input type="text" id="name" placeholder="Name">
</div>
</div>
<div class="control-group">
<label class="control-label" for="email">Email*</label>
<div class="controls">
<input type="text" id="email" placeholder="Email">
</div>
</div>
<div class="control-group">
<label class="control-label" for="subject">Subject*</label>
<div class="controls">
<input type="text" id="subject" placeholder="Subject">
</div>
</div>
<div class="control-group">
<label class="control-label" for="comment">Message*</label>
<div class="controls">
<textarea rows="4" id="comment" placeholder="Type your message here..."></textarea>
</div>
</div>
<div class="control-group">
<div class="controls">
<p> *Required fields</p>
<button type="submit" name="submit" class="btn">Submit</button>
</div>
</div>
</form>
那麼收到的電子郵件的內容是什麼? – JohnnyFaldo
嗨,我的名字是Bobby Injection,我的電子郵件地址是'[email protected] \ r \ n頭部:注射' – PeeHaa