我在 PHP 中创建了两个表单,如下所示
echo '<form name="delete" action="?page=deletetable" method="POST" autocomplete="off">';
echo '<input type=submit value="Delete" name="'.$row['TableName'].'">';
echo "</form>";
echo '<form name="assign" action="?page=assign" method="POST" autocomplete="off">';
echo '<select name="user">';
$sql = mysqli_query($con,"SELECT * FROM users WHERE hasCustom = 0");
while ($row = mysqli_fetch_array($sql)){
echo "<option value=\"".$row['user_name']. "\">" . $row['user_name'] . "</option>";
}
echo "</select>";
echo '<input type="submit" value="Assign" name="'.$row['TableName'].'">';
echo "</form>";
这看起来像下面的最后 html 代码
<form name="delete" action="?page=deletetable" method="POST" autocomplete="off">
<input type=submit value="Delete" name="rates_test">
</form>
<form name="assign" action="?page=assign" method="POST" autocomplete="off">
<select name="user">
<option value="zac">zac</option>
<option value="testadmin">testadmin</option>
<option value="tonyd">tonyd</option>
</select>
<input type="submit" value="Assign" name="">
</form>
正如您在最后一个提交按钮中看到的那样,名称标签是空的,但在第一种形式中,名称标签是正确的,即name="rates_test"
两种形式都使用相同的 PHP 来获取这个值,所以我不明白为什么一种有效而另一种无效。