0

我有一个带有两个复选框问题的表单,我正在使用 PHP 将回复放入电子邮件中。第一个仅在电子邮件中返回“数组”,即使选中了框。第二个返回选中的框值,如果没有选中则返回数组。

我已经尝试删除第二个以防它导致第一个损坏,但它仍然无法正常工作。我是 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 &amp; 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 &amp; 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>

是的,我知道内联样式有多难看,出于与这个问题无关的原因,我不得不这样做。

4

0 回答 0