使用POST方法提交表单时获取未定义的项目。
<?php
$reason = array(
"Expected delivery date has changed and the product is arriving at a later date",
"Product is being delivered to a wrong address(Customer’s mistake)",
"Product is not required anymore.",
"Cheaper alternative available for lesser price.",
"I am not going to be available in town due to some urgent travel.",
"Change in delivery address, non deliverable pincode."
);
?>
<select class="form-control" id="sel1" required>
<option>Seclect reason</option>
<?php
foreach($reason as $item){
echo '<option value="' . strtolower($item) .'">' . $item . '</option>';
}
?>
</select>
<button type="submit" class="btn btn-primary" name="cancel">Submit</button>
答案 0 :(得分:0)
您必须为name
元素设置select
属性,例如reasons
,然后才能获得$_POST['reasons']
之类的项目的值。例如:不再需要该产品。
NB 尝试使用较小的值作为您的option
值,例如,使用$reason
作为关联数组并将键设置为选项的{{ 1}}和值来选择内部文本;
value