0
在我的電子郵件中,我只接收客戶的姓名電子郵件和消息內容。只是想看看你們的想法 - 不知道爲什麼會發生這種情況。 這是我的代碼。PHP表單只顯示電子郵件中的姓名電子郵件和消息,而不是其他的
<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: [email protected]\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
這裏的電子郵件,我得到(我把旁邊工作,任何工作)
萬歲!你有一個事件查詢。
下面是詳細信息:
名稱:工作
電話:
電子郵件:工作
電話:
河段:
事件:
日期:
與會者:
住宿:
餐食:
信息:工作
非常感謝! :)
'$ _POST'是不一樣的'$ _Post' 。當涉及到變量名稱時,PHP區分大小寫 – andrewsi