以下php联系表单对我不起作用。你能帮我解决一下这个错误。 提交表单后,没有触发电子邮件。我不确定,有什么不对。以下php联系表单对我不起作用。你能帮我解决一下这个错误。
<?php
ob_start();
if(isset($_POST['your-name'])){
$to = "info@freshpotsolutions.com";
$from = $_POST['your-name'].'<'.$_POST["email"].'>';
$subject = "Enquiry Form";
$message= '<html>
<body bgcolor="#EBEBEB" style="font-family:Roboto,Arial,Helvetica,sans-serif;">
<table cellpadding="3" cellspacing="2">
<tr>
<td colspan="3" align="left"><h3>Booker Information</h3></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td width="160" > Name</td><td width="15">:</td><td>'.$_POST["your-name"].'</td>
</tr>
<tr>
<td>Email</td><td>:</td><td>'.$_POST["your-email"].'</td>
</tr>
<tr>
<td>Website</td><td>:</td><td>'.$_POST["tel-681"].'</td>
</tr>
<tr>
<td>Message</td><td>:</td><td>'.$_POST["your-message"].'</td>
</tr>
</table>
</body>
</html>';
//
$headers = "MIME-Version:1.0 \r\n";
$headers .= "Content-type:text/html; charset=iso-8859-1\r\n";
$headers .= "From: $from\r\n";
if(mail($to, $subject, $message, $headers)){
//session_destroy();
header('Location:enquiry.html?message=success');
}
}
&#13;
<form action="messageForm.php" class="wpcf7-form" method="post" novalidate>
<p><span class="wpcf7-form-control-wrap your-name"><input class=
"wpcf7-form-control wpcf7-text wpcf7-validates-as-required floatlabel"
name="your-name" placeholder="Name" size="40" type="text"></span>
</p>
<p><span class="wpcf7-form-control-wrap your-email"><input class=
"wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email floatlabel"
name="your-email" placeholder="Email" size="40" type="email"></span>
</p>
<p><span class="wpcf7-form-control-wrap tel-681"><input class=
"wpcf7-form-control wpcf7-text wpcf7-tel wpcf7-validates-as-tel floatlabel"
name="tel-681" placeholder="Phone" size="40" type="tel"></span>
</p>
<p><span class="wpcf7-form-control-wrap your-message">
<textarea class="wpcf7-form-control wpcf7-textarea floatlabel" cols=
"40" name="your-message" placeholder="Message" rows="10">
</textarea></span>
</p>
<p data-scrollreveal="enter bottom over 1s after 1s and move 50px">
<input class="wpcf7-form-control wpcf7-submit get-in-touch-submit-btn"
type="submit" value="Send">
</p>
<div class="wpcf7-response-output wpcf7-display-none">
</div>
</form>
&#13;
答案 0 :(得分:0)
更改此行
$from = $_POST['your-name'].'<'.$_POST["email"].'>';
到
$from = $_POST['your-name'].'<'.$_POST["your-email"].'>';