【发布时间】:2020-03-27 03:25:55
【问题描述】:
我的表单按钮没有通过 post 发送 var。
我已按照以下链接中的代码示例进行操作。
PHP Pass variable to next page
HTML form is not sending $_POST values
Send value of submit button when form gets posted
但继续……
注意:未定义索引:在 /public_html/test/seats.php 第 3 行进行测试
或使用isset时的空白页。
第 1 页
foreach($res as $row) {
$title = $row['Title'];
$perfDate = $row['PerfDate'];
$perfTime = $row['PerfTime'];
echo "<tr>";
echo "<td>".$title."</td>";
echo "<td>".$perfDate."</td>";
echo "<td>".$perfTime."</td>";
echo "<td><form action='seats.php' method='post'>
<input type= 'hidden' name='test' value=<?php echo $title;?> />
<input type='submit' value='Submit'></form></td>";
echo "</tr>";
}
最终我将传递行信息,以在下一个 PHP 页面上构建 SQL 查询,但是目前我什至无法发送 $title。
使用下面的代码没有给我任何东西,所以问题一定是我在第 1 页的 POST 吗?
第 2 页
<?php
$value = "";
$value = isset($_POST['test']) ? $_POST['test'] : '';
echo $value;
?>
【问题讨论】:
-
你在
var_dump($_POST);得到了什么? -
这条线看起来很可疑:
<input type= 'hidden' name='test' value=<?php echo $title;?> />$title周围的引号在哪里? -
var_dump($_POST);给出 array(1) { ["test"]=> string(5) " ,在 $title 周围加上引号,结果是一样的.. array(1) { ["test"]=> string(5) "跨度>
标签: php