在我的电子邮件中,我只收到客户的姓名电子邮件和邮件内容。只是想看看你们的想法 - 不知道为什么会发生这种情况。 这是我的代码。
<form name="sentMessage" id="contactForm" novalidate>
<div class="control-group form-group">
<div class="controls">
<label>Full Name:</label>
<input type="text" class="form-control" id="name" required data-validation-required-message="Please enter your name.">
<p class="help-block"></p>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Phone Number:</label>
<input type="text" class="form-control" name="phone" required data-validation-required-message="Please enter your phone number.">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Email Address:</label>
<input type="email" class="form-control" name="email" required data-validation-required-message="Please enter your email address.">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Best way for us to reach back to you:</label>
<input type="text" class="form-control" name="reach" required data-validation-required-message="Please enter the best way we can reach you.">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Type of event: (ex. sports/wedding/business) </label>
<input type="text" class="form-control" name="event" required data-validation-required-message="Please enter your type of event.">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Date or Weekend Desired (ex. 4/16-4/25) </label>
<input type="text" class="form-control" name="date" required data-validation-required-message="Please enter your desired date." >
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Number of Attendees:</label>
<input type="text" class="form-control" name="attendees" required data-validation-required-message="Please enter your number of attendees.">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Overnight Guests</label>
<input type="text" class="form-control" name="overnight" required data-validation-required-message="Please enter your number of overnight guests.">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Meals Included? (Yes/No/Maybe)</label>
<input type="text" class="form-control" name="meals" required data-validation-required-message="Please enter whether or not you'd like meals included.">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Additional Information:</label>
<textarea rows="10" cols="100" class="form-control" name="message" required data-validation-required-message="Please enter your message" maxlength="3999" style="resize:none"></textarea>
</div>
</div>
<div id="success"></div>
<!-- For success/fail messages -->
<button type="submit" class="btn btn-primary">Send Message</button>
</form>
这就是HTML,这就是PHP。
<?php
// check if fields passed are empty
if(empty($_POST['name']) ||
empty($_POST['phone']) ||
empty($_POST['email']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$phone = $_POST['phone'];
$email_address = $_POST['email'];
$phone =$_Post['phone'];
$reach = $_Post['reach'];
$event = $_Post['event'];
$date = $_Post['date'];
$attendees = $_Post['attendees'];
$overnight = $_Post['overnight'];
$meals = $_Post['meals'];
$message = $_POST['message'];
$to = 'me(notmyactualemail)@gmail.com';
$email_subject = "Wahnee Events Inquiry";
$email_body = "Hooray! You have an event inquiry.\n\n"."Here are the details:\n\nName: $name \n\nPhone: $phone \n\nEmail: $email_address \n\nPhone: $phone \n\nReach: $reach \n\nEvent: $event \n\nDate: $date \n\nAttendees: $attendees \n\nOvernight: $overnight \n\nMeals: $meals \n\nInfo: $message";
$headers = "From: inquiry@wahneeevents.com\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
这是我收到的电子邮件(我把工作放在旁边工作)
万岁!你有一个事件询问。
以下是详细信息:
姓名:工作
电话:
电子邮件:工作
电话:
覆盖率:
事件:
日期:
与会者:
隔夜:
餐:
信息:工作
非常感谢! :)
答案 0 :(得分:0)
将所有邮件正文变量添加到一个变量中,如:
$mesage = "Name: " . $_POST['name'];
$mesage .= $_POST['phone'];
$mesage .= $_POST['email'];
$mesage .=$_POST['phone'];
$mesage .= $_POST['reach'];
$mesage .= $_POST['event'];
$mesage .= $_POST['date'];
$mesage .= $_POST['attendees'];
$mesage .= $_POST['overnight'];
$mesage .= $_POST['meals'];
$mesage .= $_POST['message'];
只需传递$ message:
$email_body = $message;