免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2026 | 回复: 6
打印 上一主题 下一主题

简单的post [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-05-07 14:59 |只看该作者 |倒序浏览
b.php 用于提交信息:


  1. <html>
  2. <body>
  3. <form name="FrmLogin" method="post" action="a.php">
  4. <table width="774" height="300" border="0" cellspacing="0" cellpadding="0" align="center">
  5.   <tr><td><b>登录学习笔记系统</b></td></tr>
  6.   <tr><td>V 0.1</td></tr>
  7.   <tr><td>&nbsp;</td></tr>
  8.   <tr><td>用户名:<input type="text" name="user" class="input1"></td></tr>
  9.   <tr><td>密 码:<input type="password" name="passwd" class="input1"></td></tr>
  10.   <tr><td>&nbsp;</td></tr>
  11.   <tr><td><input type="submit" name="submit" value="登录" class="button1"></td></tr>

  12. </table>
  13. </form>
  14. </body>
  15. </html>
复制代码


a.php用于接收并显示:


  1. <?php

  2. if (empty($user))
  3.   $user = "lllllll--";
  4. print("$user");
  5. print("OKOKOK<br>");
  6. ?>
复制代码


为什么总是接收不到user?
在两个服务器上测试过.都不好用.
总是显示llllll--OKOKOK.

刚接触PHP.

应该是一个很简单的问题..但找不出原因

论坛徽章:
0
2 [报告]
发表于 2007-05-07 15:31 |只看该作者
$_POST['user']

论坛徽章:
0
3 [报告]
发表于 2007-05-07 22:47 |只看该作者
同意楼上echo $_POST['user']

论坛徽章:
0
4 [报告]
发表于 2007-05-08 11:14 |只看该作者
书上可能会给这样的例子,老版的PHP默认是这样

论坛徽章:
0
5 [报告]
发表于 2007-05-08 13:11 |只看该作者
OK...谢谢了...确实 $_POST['user']是可以的.....

论坛徽章:
0
6 [报告]
发表于 2007-05-16 13:05 |只看该作者
今天翻了一下php manual Chapter 29. Using Register Globals
php4.2.0把register_globals默认值从on改成off, 原因是


  1. <?php
  2. // define $authorized = true only if user is authenticated
  3. if (authenticated_user()) {
  4.     $authorized = true;
  5. }

  6. // Because we didn't first initialize $authorized as false, this might be
  7. // defined through register_globals, like from GET auth.php?authorized=1
  8. // So, anyone can be seen as authenticated!
  9. if ($authorized) {
  10.     include "/highly/sensitive/data.php";
  11. }
  12. ?>
复制代码

When register_globals = on, our logic above may be compromised. When off, $authorized can't be set via request so it'll be fine

所以, 现在用$_POST[], $_GET[]这样的形式比较安全一点.
(4.2.0以前的phper, 可以通过给$authorized设置默认值来避免这个问题)

论坛徽章:
0
7 [报告]
发表于 2007-05-16 13:20 |只看该作者
import_request_variables( 'gp' );
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP