我有一个包含两个复选框问题的表单,我正在使用PHP将回复放入电子邮件中。第一个只返回电子邮件中的“数组”,即使选中了复选框。第二个返回选中的复选框值,如果没有选中则返回Array。
我已经尝试删除第二个以防它导致第一个中断,但它仍然无效。我是PHP的新手,任何人都可以帮我弄清楚为什么这不起作用?
我提交表单时没有看到任何错误或警告。这是相关的PHP:
$ownership = array();
if(isset($_POST['ownership'])) $ownership = nl2br(implode(', ', $_POST['product-types-owned']));
$firstprod = nl2br($_POST['First_prod']);
$cook = array();
if(isset($_POST['cook'])) $cook = nl2br(implode(', ', $_POST['cook']));
以下是表单中不起作用的部分(不在电子邮件中打印):
<input type="checkbox" name="product-types-owned[]" style="outline: none; border: none;" value="Cast_Iron_Ovens_and_Braisers" /> Cast Iron Ovens & Braisers</label>
<label style="line-height: 1.8;vertical-align: top; display: block; margin-left: 10px; width: auto;" for="Skillets_and_Grills">
<input type="checkbox" name="product-types-owned[]" style="outline: none; border: none;" value="Skillets_and_Grills" /> Skillets & Grills</label>
<label style="line-height: 1.8;vertical-align: top; display: block; margin-left: 10px; width: auto;" for="Specialty">
<input type="checkbox" name="product-types-owned[]" style="outline: none; border: none;" value="Specialty" /> Specialty</label>
<label style="line-height: 1.8;vertical-align: top; display: block; margin-left: 10px; width: auto;" for="Tri-Ply_Stainless_Steel">
<input type="checkbox" name="product-types-owned[]" style="outline: none; border: none;" value="Tri-Ply_Stainless_Steel" /> Tri-Ply Stainless Steel</label>
<label style="line-height: 1.8;vertical-align: top; display: block; margin-left: 10px; width: auto;" for="Forged_Hard-Anodized">
<input type="checkbox" name="product-types-owned[]" style="outline: none; border: none;" value="Forged_Hard-Anodized" /> Forged Hard-Anodized</label>
以下是正在运行的表单的一部分:
<input type="checkbox" name="cook[]" style="outline: none; border: none;" value="Slow_Cooking" /> Slow Cooking</label>
<label style="line-height: 1.8;vertical-align: top; display: block; margin-left: 10px; width: auto;" for="Kid_Friendly_Meals">
<input type="checkbox" name="cook[]" style="outline: none; border: none;" value="Kid_Friendly_Meals" /> Kid Friendly Meals</label>
<label style="line-height: 1.8;vertical-align: top; display: block; margin-left: 10px; width: auto;" for="Holiday_Entertaining">
<input type="checkbox" name="cook[]" style="outline: none; border: none;" value="Holiday_Entertaining" /> Holiday Entertaining</label>
<label style="line-height: 1.8;vertical-align: top; display: block; margin-left: 10px; width: auto;" for="International">
<input type="checkbox" name="cook[]" style="outline: none; border: none;" value="International" /> International</label>
<label style="line-height: 1.8;vertical-align: top; display: block; margin-left: 10px; width: auto;" for="Quick_and_Easy">
<input type="checkbox" name="cook[]" style="outline: none; border: none;" value="Quick_and_Easy" /> Quick and Easy</label>
是的,我知道内联样式有多丑,我必须这样做是出于与此问题无关的原因。