php $GET与$POST获取表单内容

       一个form表单内容如下:   

<html> 
<body>
<form action="server.php" method="get">
name: <input type="text" name="name">
age: <input type="text" name="age">
submit: <input type="submit" name="submit">
</form>
</body>
</html>

       将form表单提交给server.php,server.php内容如下:

<html>
<body>
Welcome <?php echo $_GET["name"] . " "; ?>
You are <?php echo $_GET["age"] . " "; ?> years old!
</body>
</html>

       如果用POST方法,将form表单里的method改为post,将server.php里的$GET改为$POST即可。

原创文章,转载请注明: 转载自空空博客

本文链接地址: php $GET与$POST获取表单内容

文章的脚注信息由WordPress的wp-posturl插件自动生成