Discuz教程网

PHP的一个基础知识 表单提交

[复制链接]
authicon dly 发表于 2011-8-30 19:27:52 | 显示全部楼层 |阅读模式
register.php:
代码如下:

  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html;charset=gb2312">
  4. <title>注册页面</title>
  5. </head>
  6. <body>
  7. <form action="request.php" method="post" name="registForm">
  8. <table width="330" border="0" align="center" cellpadding="5" bgcolor="#eeeeee">
  9. <tr>
  10. <td width="40%">用户名:</td>
  11. <td><input name="username" type="text" id="username"/></td>
  12. </tr>
  13. <tr>
  14. <td>姓名:</td>
  15. <td><input name="name" type="text" id="name"/></td>
  16. </tr>
  17. <tr>
  18. <td>密码:</td>
  19. <td><input name="pwd" type="text" id="pwd"/></td>
  20. </tr>
  21. <tr>
  22. <td>邮箱:</td>
  23. <td><input name="email" type="text" id="email"/></td>
  24. </tr>
  25. <tr>
  26. <td colspan="2" align="center">
  27. <input type="submit" value="提交" name="submit"/>
  28. <input type="reset" value="重置" name="button"/>
  29. </td>
  30. </tr>
  31. </table>
  32. </form>
  33. </body>
  34. </html>
复制代码

request.php

代码如下:

  1. <?php
  2. $username = $_POST['username'];
  3. $name = $_POST['name'];
  4. $pwd = $_POST['pwd'];
  5. $email = $_POST['email'];
  6. //print_r($username);
  7. if(!empty($username))
  8. {
  9. echo "您填写的信息为:<br>\n";
  10. echo "用户名: $username <br>\n";
  11. echo "姓名: $name <br>\n";
  12. echo "密码: $pwd <br>\n";
  13. echo "邮箱: $email <br>\n";
  14. }
  15. print_r($_POST)
  16. //echo "aaaa";
  17. ?>
  18. </PRE>
  19. </DIV>
复制代码




当然,你也可以把request跟regiser.php写到一起。




上一篇:PHP与mysql建立连接并执行SQL语句的代码
下一篇:PHP和Mysqlweb应用开发核心技术-第1部分 Php基础-2 PHP语言介绍
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-7-5 04:11

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表