Php 无法使用复选框发送表单
我想发送一个表格,其中有复选框,它工作正常,但我不知道我做了什么,现在我收到了一个错误,每次我发送它。我认为这个问题与复选框有关,因为我记得我过去在复选框上遇到过问题。我正在用PHP处理一个文件 这是表单的代码:Php 无法使用复选框发送表单,php,html,forms,checkbox,Php,Html,Forms,Checkbox,我想发送一个表格,其中有复选框,它工作正常,但我不知道我做了什么,现在我收到了一个错误,每次我发送它。我认为这个问题与复选框有关,因为我记得我过去在复选框上遇到过问题。我正在用PHP处理一个文件 这是表单的代码: <div class="contactFrm"> <?php if(!empty($statusMsg)){ ?> <p class="statusMsg <?php echo !empty($msgClass)?$msgC
<div class="contactFrm">
<?php if(!empty($statusMsg)){ ?>
<p class="statusMsg <?php echo !empty($msgClass)?$msgClass:''; ?>"><?php echo $statusMsg; ?></p>
<?php } ?>
<form action="" method="post">
<h6>Contact Information</h6>
<fieldset id="left">
<h4>First Name</h4>
<input type="text" name="name" required>
<h4>Company Name</h4>
<input type="text" name="compname" required>
<h4>Phone Number</h4>
<input type="text" name="phone" required>
<h4>Date of Arrival</h4>
<input type="date" name="ardate" required>
</fieldset>
<fieldset id="right">
<h4>Last Name</h4>
<input type="text" name="lname" required>
<h4>Website URL</h4>
<input type="text" name="website" required>
<h4>Email</h4>
<input type="email" name="email" required>
<h4>Date of Departure</h4>
<input type="date" name="depdate" required>
</fieldset>
<h4>What is your estimated time of arrival?</h4>
<input type="text" name="estimated_time" required>
<h4>How many groups will you be hosting?</h4>
<textarea name="groups" required> </textarea>
<h4>How many participants per group do you need to accommodate?</h4>
<input type="text" name="mparticipants" required>
<h4>What are the date/time scheduled for each group?</h4>
<textarea name="scheduled" required> </textarea>
<h4>What kind of set-up will you like?</h4>
<p>Additional fees may apply for living room/specialty set-ups.</p>
<p><div class="inline-field">
<label>
<input type="checkbox" name="CheckboxGroup1[]" value="living_room" id="CheckboxGroup1_0">
Living Room</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup1[]" value="conference_room" id="CheckboxGroup1_1">
Conference Room</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup1[]" value="other" id="CheckboxGroup1_2">
Other (please specify at the end of the form)</label>
<br>
</div></p>
<h6>Clients</h6>
<h4>How many individuals/clients from your company will be attending?</h4>
<p>These individuals will be stationed in the client room.</p>
<input type="text" name="attending">
<h6>Services</h6>
<h4>Which technology services are you interested in?</h4>
<p>Check all that apply (All of these services are charged separately. Some will involve additional costs from the estimate provided to you.)</p>
<p><div class="inline-field">
<label>
<input type="checkbox" name="CheckboxGroup2[]" value="sd_dvd" id="CheckboxGroup2_0">
Stationary SD DVD Recording</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup2[]" value="hd_video" id="CheckboxGroup2_1">
Stationary HD Video Recording</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup2[]" value="streaming" id="CheckboxGroup2_2">
High Definition Video Streaming (Focus Vision (SD) streaming is also available)</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup2[]" value="smartboard" id="CheckboxGroup2_3">
Smartboard (also functions as TV/DVD/PC)</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup2[]" value="translation" id="CheckboxGroup2_4">
Translation Equipment</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup2[]" value="videographer" id="CheckboxGroup2_5">
Videographer Assisted Recording (SD/HD)</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup2[]" value="other" id="CheckboxGroup2_6">
Other (please specify on notes section)</label>
<br>
</div></p>
<h4>Will you need meal(s) to be provided?</h4>
<p>You will be able to pick from various menus once the booking is confirmed.</p>
<p><div class="inline-field">
<label>
<input type="checkbox" name="CheckboxGroup3[]" value="participants" id="CheckboxGroup3_0">
Yes, for Participants</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup3[]" value="clients" id="CheckboxGroup3_1">
Yes, for Clients</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup3[]" value="breakfast" id="CheckboxGroup3_2">
Breakfast</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup3[]" value="lunch" id="CheckboxGroup3_3">
Lunch</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup3[]" value="dinner" id="CheckboxGroup3_4">
Dinner</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup3[]" value="snacks" id="CheckboxGroup3_5">
Snacks</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup3[]" value="beverages" id="CheckboxGroup3_6">
Beverages</label>
<br>
</div></p>
<h4>Do you need research service(s)?</h4>
<p>Check all that apply.</p>
<p><div class="inline-field">
<label>
<input type="checkbox" name="CheckboxGroup4[]" value="moderator" id="CheckboxGroup4_0">
Moderator(s)</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup4[]" value="recruiting" id="CheckboxGroup4_1">
Recruiting</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup4[]" value="reporting" id="CheckboxGroup4_2">
Reporting and Analysis</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup4[]" value="quantitative" id="CheckboxGroup4_3">
Quantitative</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup4[]" value="other" id="CheckboxGroup4_4">
Other Research Services (please specify in the notes section)</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup4[]" value="na" id="CheckboxGroup4_5">
N/A</label>
<br>
</div></p>
<h6>Additional Information</h6>
<h4>Please include any additional information or document that would help us facilitate your request.</h4>
<textarea name="additionalinfo"> </textarea>
<h4>Document Upload</h4>
<input type="file">
<input type="submit" name="submit" value="Submit">
<div class="clear"> </div>
</form>
如果您能帮我指出错误,我们将不胜感激。我已经检查了您的代码,每次代码都正常工作,但如果未选中复选框,您将无法处理该错误,请处理它, 可能是使用未命中复选框选择。
另一方面,发生了什么类型的错误 如果您收到此消息: 您的联系请求提交失败,请重试 然后这部分代码将抛出该消息:
// Send email
if(mail($toEmail,$emailSubject,$htmlContent,$headers)){
$statusMsg = 'Your contact request has been submitted successfully !';
$msgClass = 'succdiv';
}else{
$statusMsg = 'Your contact request submission failed, please try again.';
$msgClass = 'errordiv';
}
这意味着mail()函数返回false。确保mail()函数通过传入您知道有效的参数来工作,例如您所说的其他联系人表单中的参数。另外,也许可以尝试删除$headers,看看这是否有帮助,因为该部分是可选的。提醒:如果未选中复选框,它们将不会设置在$\u POST superglobalAlso中,请下次只显示足够的代码来确定问题“我每次发送时都收到错误”-什么错误?请提供,强调最小。使用不会有什么坏处(而且你的标题排序也很奇怪)。我发现错误:你的联系请求提交失败,请重试。我没有收到任何电子邮件。
// Send email
if(mail($toEmail,$emailSubject,$htmlContent,$headers)){
$statusMsg = 'Your contact request has been submitted successfully !';
$msgClass = 'succdiv';
}else{
$statusMsg = 'Your contact request submission failed, please try again.';
$msgClass = 'errordiv';
}