【发布时间】:2018-04-27 19:09:33
【问题描述】:
我在 php 文件中编写了一个表单,并使用 post 方法将值发送到下一页。但是变量不会发送到下一页。我做错了什么?
在下面的代码中,我无法获取帖子值。它说 $dbid 未定义!
echo '<table width = "30%" cellpadding = "2" cellspacing ="2" border = "2px">
echo '<table width = "30%" cellpadding = "2" cellspacing ="2" border = "2px">
<tr>
<form action="sample.php" method="POST">
<td> <input type="text" name="dbid" value='.$row['ID'].' size="4" readonly ></td>
<button type="submit" name="submit" >view form</button>
</form>
<td>'.$row['username'].'</td>
<td>'.$row['ecno'].'</td>
<td>'.$row['division'].'</td>
<td>'.$row['code'].'</td>
<td>'.$row['doj'].'</td>
<td>'.$row['dor'].'</td>
<td>'.$row['fc'].'</td>
<td>'.$row['tc'].'</td>
</tr>
示例.php:
<?php
$dbid= $_POST['dbid'];
$db = mysqli_connect("localhost", "root", "", "logindb1");
if (mysqli_connect_errno())
{
echo "something went wrong with the connection" . mysqli_connect_error();
}
echo ' <input type="hidden" name="dbid" value="'.$_POST['dbid'].'"> ';
$query = mysqli_query($db,"SELECT * FROM users2 WHERE ID ='$dbid'");
【问题讨论】:
-
首先请修复您的 HTML - 它很糟糕而且无效。也永远不要命名任何东西 name="submit - 它隐藏了表单的提交事件。
标签: php html forms session post