0

这是表单代码:

<?php
$con=mysqli_connect("localhost","user","pass","db");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$result = mysqli_query($con,"SELECT ID, NAME FROM b_sonet_group ORDER BY ID DESC");


echo "<form class='form-vertical login-form' action='step-2.php' method='POST'>";

echo "<h4 class='form-title'>Step One: Choose Your Project</h4><div class='control-group'><div class='controls'>";              

echo "<select>";
echo "<option value=''>Choose Your Project</option>";

while($row = mysqli_fetch_array($result))

  {
  echo "<option name='ID' value='" . $row['ID'] . "'>" . $row['NAME'] . "</option>";
  }
  echo "</select>";

  echo "</div></div>";

  echo "<div class='form-actions'><button type='submit' name='submit' class='btn green pull-right'>Proceed to Step Two <i class='m-icon-swapright m-icon-white'></i></button></div></form>";


mysqli_close($con);
?>

我需要在第 2 页上放什么从上一页的表单中检索值 ID 以及如何打印它以便我可以检查它是正确的 ID?

我知道很简单,但我的大脑已经收拾好回家了。

4

2 回答 2

3

你需要改变你select

echo "<select name=\"project\">";

在您的第二页上,您可以获得价值

echo $_POST['project'];
于 2013-09-18T16:10:38.720 回答
0

您需要将名称从选项移动到您的选择。然后回显 $_POST['id'];

于 2013-09-18T16:11:52.677 回答