2 つのページがあり、一方は POST を介して他方に値を渡します。値は、選択アクションの 2 ページ目に表示されません。入力テキストボックスはその値を渡します。以下の両方のページを含めました
先頭ページ:
mysql_connect("localhost","root","") or die("Unable to connect");
mysql_select_db("testsite");
$sql = "SELECT state FROM states";
$result = mysql_query($sql);
$sqldegrees = "SELECT degree FROM degrees";
$resultdegrees = mysql_query($sqldegrees);
$sqlschools = "SELECT school FROM schools";
$resultschools = mysql_query($sqlschools);
echo "<html>";
echo "<head>";
echo "<link rel='stylesheet' type='text/css' href='styles.css'/>";
echo "</head>";
echo "<body>";
echo "<h3>Education</h3>";
echo "<form method='post' action='educationhistoryinsert.php'>";
echo "<table border='3' width='280'>";
echo "<tr><td>State:</td><td>";
echo "<select state='state'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['state'] ."'>" . $row['state'] ."</option>";}
echo "</select>";
echo "</td></tr>";
echo "<tr><td>School:</td><td>";
echo "<select school='school'>";
while ($row = mysql_fetch_array($resultschools)) {
echo "<option value='" . $row['school'] ."'>" . $row['school'] ."</option>";}
echo "</select>";
echo "</td></tr>";
echo "<tr><td>Degree:</td><td>";
echo "<select degree='degrees'>";
while ($row = mysql_fetch_array($resultdegrees)) {
echo "<option value='" . $row['degree'] ."'>" . $row['degree'] ."</option>";}
echo "</select>";
echo "</td></tr>";
echo "<tr><td>Subject:</td><td><input type='text' name='subject' maxlength='20'/></td>
</tr>";
echo "</table>";
echo "<table border='1'>";
echo "<tr>";
echo "<td width='5'>Month:</td><td><input style='width: 30px;' type='number'
name='month' maxlength='1'/></td>";
echo "<td width='5'>Year:</td><td><input style='width: 50px;' type='number'
name='year' maxlength='5'/></td>";
echo "<td width='5'>GPA:</td><td><input style='width: 30px;' type='number' name='gpa'
maxlength='5'/></td>";
echo "</tr>";
echo "</table>";
echo "<input type='submit' value='Save'>";
echo "</form>";
echo "</body>";
echo "</html>";
?>
=======----------------------------------------------「教育史挿入.php」
<?php
$degree = $_POST['degree'];
$subject = $_REQUEST['subject'];
echo $degree."<br/>";
?>