【发布时间】:2017-07-27 19:39:35
【问题描述】:
我有这段代码可以在 php 表单中填充表格的行
$html = '<tr>';
$html .= '<td class="tg-yw4l"><input type="text" name="exam_date_input[]" value="' . $exam_date . '"></td>';
$html .= '<td class="tg-yw4l"><input type="text" name="exam_code_input[]" value="' . $exam_code . '"></td>';
$html .= '<td class="tg-yw4l"><input type="text" name="exam_title[]" value="' . $title . '"></td>';
$html .= '<td class="tg-yw4l"><input type="text" name="exam_time_input[]" value="' . $exam_time . '"></td>';
$html .= "<td class='tg-yw4l'><a href='javascript:void(0)' class='row_remove'> - </a></td>";
$html .= '<tr>';
die($html);
这是我检查元素时显示的 HTML
<input name="exam_date_input[]" value="01/03/2017" type="text">
理论上,提交表单应该将此数组添加到 $POST 数组中。
然而这并没有发生。
相反,我的表单操作页面 $date = $_POST['exam_date_input']; 上的这段代码给出了以下通知:
Notice: Undefined index: exam_date_input
并且在 $POST 数组中没有使用 var_dump($_POST); 的 exam_date_input 数组
【问题讨论】:
-
这个表单是如何提交的?
die()命令意味着这是您的 HTML 的全部,这意味着没有实际的表单。你还提交什么? -
print_r($_POST);向您展示了什么?鉴于这些输入,不会有$_POST['exam_date_input']。