form.html: <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> </head> <body> <form action="welcome.php" method="post"> 名字: <input type="text" name="fname"> 年龄: <input type="text" name="age"> <input type="submit" value="提交"> </form> </body> </html>
welcome.php
Welcome<?php echo $_POST["fname"]; ?>!<br>
Your age is<?php echo $_POST[ "age"]; ?> years old.
王林2019-08-20 17:51:55
Another issue that needs attention is that when opening form.html, you must open it by entering the URL, otherwise welcome.php will be displayed as a pure code page
kanglecheng2019-07-19 14:41:15
The two files must be in the same directory, such as
page/form.html
page/welcome.php