| 99-2-第一週(2) type=text練習<?php $PHP_SELF=$_SERVER["PHP_SELF"]; $command=$_POST['command']; // 取出變數值 if ($command==null) { // 空值, 未經由form傳送 echo "<html>"; echo "<body>"; echo "<center>"; echo "<form method=post action=$PHP_SELF>"; echo "班級:"; echo "<input type=text name=depart_class size=10>"; echo "<p>"; echo "<input type=submit name=command value=送出>"; echo "<input type=reset name=command value=清除>"; echo "</form>"; echo "</center>"; echo "</body>"; echo "</html>"; } else if ($command=='送出') { $depart_class=$_POST["depart_class"]; echo "<html>"; echo "<body>"; echo "<center>"; echo "<form method=post action=$PHP_SELF>"; echo "班級:"; echo "<input type=text name=depart_class size=10 value='$depart_class'>"; echo "<p>"; echo "<input type=submit name=command value=送出>"; echo "<input type=reset name=command value=清除>"; echo "</form>"; echo "</center>"; echo "</body>"; echo "</html>"; } ?> 參考前述範例,改寫程式使第二個畫面和第一個畫面一樣,但顯式輸入的值 | |