问题描述
PHP联系人表格不起作用。进行了彻底检查,但仍然遇到问题。分开(HTML)和处理程序(PHP)。有时一条消息只是带有:
这是HTML表单中的表单部分。
<form class="contactForm" action="contact.PHP" method="POST" enctype="multipart/form-data" name="contactForm" data-toggle="validator">
<div class="formGroup">
<label class="formlabel" for="name">Your Name</label>
<input class="formField" id="name" type="text" name="name" required="" data-error="Please enter your name"/>
<div class="help-block with-errors"></div>
</div>
<div class="formGroup">
<label class="formlabel" for="phone">Phone Number</label>
<input class="formField" id="phone" type="text" name="phone" required="" data-error="Please enter your phone number"/>
<div class="help-block with-errors"></div>
</div>
<div class="formGroup">
<label class="formlabel" for="email">Email</label>
<input class="formField" id="email" type="email" name="email" required="" data-error="Please enter your Email"/>
<div class="help-block with-errors"></div>
</div>
<div class="formGroup">
<label class="formlabel" for="message">Message</label>
<textarea class="formField" id="message" rows="3" name="message" required="" data-error="Write your message"></textarea>
<div class="help-block with-errors"></div>
</div>
<div class="buttonWrapper">
<button type="submit">Send Message</button>
</div>
</form>
这是单独的PHP部分:
<?PHP
// setting up fields:
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$message = $_POST['message'];
// what they write in the body of the message:
$email_from = 'mysite.net';
$email_subject = 'New Message from contact form';
$email_body = "Name: $name.\n".
"Phone: $phone.\n".
"Email: $email.\n".
"Message: $message.\n";
// Where to send it:
$to ="[email protected]";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $email \r\n";
mail($to,$email_subject,$email_body,$headers);
// Where to go to after sending contact form.
header("location: messageThanks.html");
?>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)