您好,我正在为合作伙伴制作联系表格。他希望能够让人们请求时间和日期。我使用了php邮件程序,它在使用输入类型文本时有效,但当我添加(jQuery)日期选择器和时间(选择)时,它不会发送电子邮件。任何帮助将不胜感激。
我在下面的html表单的最后一位添加了php邮件代码。 对于时间选择使用name =“rtime”,对日期选择器使用name =“rdate”。
以下表格代码_ _ _
<select name="rtime" id="">
<option value="" name="9am">9:00am</option>
<option value="" name="10am">10:00am</option>
<option value="" name="11am">11:00am</option>
<option value="" name="12pm">12:00pm</option>
<option value="" name="1pm">1:00pm</option>
<option value="" name="2pm">2:00pm</option>
<option value="" name="3pm">3:00pm</option>
<option value="" name="4pm">4:00pm</option>
</select>
<input type="text" id="datepicker" placeholder="Reqested Date" class="block col-10 mb2 field" name="rdate">
PHP MAILER CODE - - - -
要求'./PHPMailerAutoload.php';
如果(isset($ _ POST [ “名称”])){
$name = $_POST["name"];
$fromEmail = $_POST["email"];
$phone = $_POST["phone"];
$message = $_POST["message"];
$rTime = $_POST["rtime"];
$rDate = $_POST["rdate"];
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Set who the message is to be sent from
$mail->setFrom($fromEmail, 'Whitersmile Website Enquiry');
//Set an alternative reply-to address
$mail->addReplyTo($fromEmail, $name);
//Set who the message is to be sent to
$mail->addAddress('info@whitersmile.co.nz', 'Whitersmile Website Enquiry');
//Set the subject line
$mail->Subject = $name . ' has enquired on the website';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML("Name: ".$name."<br> Phone: ".$phone ."<br> Email: " .$fromEmail."<br> Requested time: ".$rTime."<br> Requested date: ".$rDate.
“
留言:”。$ message);
//用手动创建的纯文本正文替换
//send the message, check for errors
if (!$mail->send()) {
header("Location:../index.php#formWrapperContact");
} else {
header("Location:../index.php?message=Thank+You#thankyouMessage");
}
//header("");
}