-1
用戶在輸入姓名和年齡後提交時,代碼不起作用。頁面應提交到同一頁面,並且HTML表單也應與下面的結果一起顯示。請幫助我的傢伙!PHP表單不工作
<html>
<head>
\t <title>My first PHP page</title>
</head>
<body>
\t \t <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <!-- $_SERVER['PHP_SELF'] array -->
\t \t \t Name: <input type="text" name="name"/>
\t \t \t Age: <input type="text" name="age"/>
\t \t \t <input type="submit"/>
\t \t </form>
</body>
</html>
<?php
/* because both the HTML form data and the PHP processing code are in the same script, you will need a conditional check to
see if the form has been submitted */
if (isset($_POST['submit'])) { //was the form submitted?
print "Raveen";
//echo "Welcome ". $_POST["name"] . "<br>";
//echo "You are $_POST["age"] years old<br>";
//echo "The path to this file is: $_SERVER[PHP_SELF]";
}
?>
謝謝你,先生!我在幾分鐘內解決了我的問題+瞭解了額外的點(隱藏的輸入)。 – Ishani