我在php文件中编写了一个表单,并使用post方法将值发送到下一页。但是变量不会发送到下一页。我做错了什么?
在下面的代码中,我无法获得帖子值。它说$ dbid undefined!
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>
Sample.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'");
答案 0 :(得分:2)
使用代码而不是创建提交按钮
<强>代码强>
<input type="submit" name="submit" >view form</button>
而不是
<button type="submit" name="submit" >view form</button>