在询问之前检查了所有其他资源,但它没有回答我的问题。无论如何,为什么我没有收到所有信息?感谢。
这是我的PHP:
<?php
$message = "Name: " . $_POST['name'];
$message .= "\r\nPhone " . $_POST['phone'];
$message .= "\r\nEmail: " . $_POST['email'];
$message .= "\r\nRequested Form of Contact: " . $_POST['reach'];
$message .= "\r\nEvent Type: " . $_POST['event'];
$message .= "\r\nRequested Dates: " . $_POST['date'];
$message .= "\r\nNumber of Attendees: " . $_POST['attendees'];
$message .= "\r\nOvernight Guests: " . $_POST['overnight'];
$message .= "\r\nMeals Included?: " . $_POST['meals'];
$message .= "\r\nAdditional Information: " . $_POST['message'];
$to = 'nosdg@testfakel.com';
$email_subject = "Fake Subject";
$email_body = $message;
$headers = "From: iauto@can.com\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
HTML表单:
<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">
<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" id="phone">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Email Address:</label>
<input type="email" class="form-control" id="email">
</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" id="reach">
</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" id="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" id="date">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Number of Attendees:</label>
<input type="text" class="form-control" id="attendees">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Overnight Guests</label>
<input type="text" class="form-control" id="overnight">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Meals Included? (Yes/No/Maybe)</label>
<input type="text" class="form-control" id="meals">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Additional Information:</label>
<textarea rows="10" cols="100" class="form-control" id="message" maxlength="39999" 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>
我知道为什么我只收到姓名,电话,电子邮件和其他信息?
谢谢!
答案 0 :(得分:0)
替换此表单并请分享javascript代码(如果您使用的话)
<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" name='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" id="phone" name='phone'>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Email Address:</label>
<input type="email" class="form-control" id="email" name='email'>
</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" id="reach" name='reach'>
</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" id="event" name='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" id="date" name='date'>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Number of Attendees:</label>
<input type="text" class="form-control" id="attendees" name='attendees'>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Overnight Guests</label>
<input type="text" class="form-control" id="overnight" name='overnight'>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Meals Included? (Yes/No/Maybe)</label>
<input type="text" class="form-control" id="meals" name='meals'>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Additional Information:</label>
<textarea rows="10" cols="100" class="form-control" id="message" name='name' maxlength="39999" 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>
答案 1 :(得分:0)
发布为社区维基。
如果省略, <form>
默认为GET方法。 (参考我的脚注)
<form name="sentMessage" id="contactForm" novalidate>
所以添加一个POST方法:
<form method="post" name="sentMessage" id="contactForm" novalidate>
因为你正在使用POST数组。
然后你的所有输入都没有name属性,你只依赖于id。
<input type="text" name="name" class="form-control" id="name">
^^^^^^^^^^^
并为其余输入做同样的事情。
将error reporting添加到文件的顶部,这有助于查找错误。
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Then the rest of your code
旁注:只应在暂存时进行显示错误,而不是生产。
<强>脚注:强>
如果你正在使用JS / Ajax,你没有发帖,我怀疑你是,那么用你正在使用的代码编辑你的问题。