我最近爲我的朋友做了一個網站,幷包含一個使用PHP的聯繫表。當人發送電子郵件時,數據不通過電子郵件發送。聯繫表格在PHP中發送空白數據
這是網站
<article class="grid_8">
<div class="indent-left">
<h3 class="p1">Contact us</h3>
<form id="contact-form" method="post" name="myemailform" action="contact_form.php">
<fieldset>
<label><span class="text-form">Name:</span><input name="name" type="text" required /></label>
<label><span class="text-form">Email:</span><input name="email" type="text" required /></label>
<label><span class="text-form">Phone:</span><input name="phone" type="text" /></label>
<div class="wrapper">
<div class="text-form">Message:</div>
<div class="extra-wrap">
<textarea name="message" required></textarea>
<div class="clear"></div>
<div class="buttons">
<input type="submit" value="Submit" class="button">
</div>
</div>
</div>
</fieldset>
</form>
</div>
</article>
代碼這是PHP
<?php
$name = $_POST['name'];
$message = $_POST['message'];
$phone = $_POST['phone'];
$email_from = $_POST['email'];
$email_subject = $_POST["New Message From www.chevroncreativesolutions.com"];
$email_body = $_POST["You have received a new message from $name.\n".
"Here is the message:\n $message.\n You Can call me on $phone.\n"].
$to = "[email protected]";
$headers = "From: $email_from \r\n";
$contact_form=mail($to,$email_subject,$email_body,$headers);
if($contact_form) {
echo "Message has been sent.";
echo "<form><input type='button' value='Return back' onclick='history.back();'></form>";
} else {
echo "Error In sending your message";
echo "<form><input type='button' value='Return back' onclick='history.back();'></form>";
}
工作完美,我試圖解決這個問題一段時間,現在謝謝你 – 2014-09-30 18:34:26