PHP 基础教程:PHP 表单和用户输入
$_GET 和$_POST 用于检索表单中的值,比如用户输入。
PHP 表单处理
表单实例:
<html>
<body>
<formaction="welcome.php"method="post">
Name:<inputtype="text"name="name"/>
Age:<inputtype="text"name="age"/>
<inputtype="submit"/>
</form>
</body>
</html>
上面的 HTML 页面实例包含了两个输入框和一个提交按钮。当用户填写该表单并单击
提交按钮时,表单的数据会被送往"welcome.php"这个文件。
"welcome.php"文件类似这样:
<html>
<body>
Welcome<?phpecho$_POST["name"];?>.<br/>
Youare<?phpecho$_POST["age"];?>yearsold.
</body>
</html>
上面这个脚本的输出样本类似这样: