-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