您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php 表单提交实例代码

2025/12/24 6:12:59发布16次查看
php接受通过html表单提交的信息时,会将提交的数据保存在全局数组中,我们可以调用系统特定的自动全局变量数组来获取这些值。常用的自动全局变量如下所示:
$_get
$_post
$_request
在获取表单数据中,最常用的自动全局变量是$_get和$_post,它们分别获取通过get方法提交的数据和通过post方法提交的数据。 比如一个名称为user的文本框表单控件,如果用get方法提交,可以用
$_get[user]或者$_get['user']
实例代码
register.php: 
<html> <head> <meta http-equiv="content-type" content="text/html;charset=gb2312"> <title>注册页面</title> </head> <body> <form action="request.php" method="post" name="registform"> <table width="330" border="0" align="center" cellpadding="5" bgcolor="#eeeeee"> <tr> <td width="40%">用户名:</td> <td><input name="username" type="text" id="username"/></td> </tr> <tr> <td>姓名:</td> <td><input name="name" type="text" id="name"/></td> </tr> <tr> <td>密码:</td> <td><input name="pwd" type="text" id="pwd"/></td> </tr> <tr> <td>邮箱:</td> <td><input name="email" type="text" id="email"/></td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" value="提交" name="submit"/> <input type="reset" value="重置" name="button"/> </td> </tr> </table> </form> </body> </html>
request.php
<?php $username = $_post['username']; $name = $_post['name']; $pwd = $_post['pwd']; $email = $_post['email']; //print_r($username); if(!empty($username)) { echo "您填写的信息为:<br>\n"; echo "用户名: $username <br>\n"; echo "姓名: $name <br>\n"; echo "密码: $pwd <br>\n"; echo "邮箱: $email <br>\n"; } print_r($_post) //echo "aaaa"; ?> </pre> </p>
以上就是php 表单提交实例代码的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product