$_SERVER['PHP_SELF']
post变量 $_POST['narname']
get变量 $_GET['narname']

解决方案 »

  1.   

    $_SERVER['PHP_SELF'];当前正在执行脚本的文件名,与 document root相关。举例来说,在URL地址为 http://example.com/test.php/foo.bar 的脚本中使用 $_SERVER['PHP_SELF'] 将会得到 /test.php/foo.bar 这个结果。 
      

  2.   

    来晚了,呵呵。$PHP_SELF可以用$_SERVER["PHP_SELF"]
    post和get上面的都说完了,还有两个。Cookie和Session的用法分别为:$_COOKIE和$_SESSION
      

  3.   

    来来来,各位,请帮忙,把下面这段程序完整可以运行一下<form method=POST NAME=$userlogin ACTION=$PHP_SELF>
    <table>
    <tr><td>工号</td><td><input type=text name=agntnum size=20></td></tr>
    <tr><td>密码</td><td><input type=password name="passwd"  size=20></td></tr>
    <tr><td colspan=2><input name=login type=submit value="进 入"></td>
        <td colspan=2><input name=reset type=reset value="取 消"></td>
    </tr>
    </table>
    </form>
    <?
    $agntnum=$_POST['agntnum'];
    $passwd =$_POST['passwd'];
    mssql_select_db('XX');if(isset($_POST['agntnum'])&&$_POST['agntnum']!='')
    {
    $query = "SELECT passwd FROM master WHERE agntnum='".$agntnum."'"; 
    $res = mssql_query($query,$conn);
    $arr = mssql_fetch_array($res);
    //原因同上
    if(isset($_POST['passwd'])&&$_POST['passwd']!='')
    {
    if ($arr['passwd'] <> $_POST['passwd'])
    {
    echo "错误的用户名或密码,请<a href=\"./index.php\">重新登陆</a>";
    }
    else 
    {
    include "./main.php";

    }
    }

    }?>
      

  4.   

    <?
    if ("进 入"==$_REQUEST['login']){
    //判断帐号密码
    //如果密码错误

    $errmsg="密码错误";

    //如果密码正确
    // header(...);
    // exit;
    }
    ?>
    <form method=POST>
    <table>
    <tr><td colspan=2><font color=red><?=$errmsg?></font></td></tr>
    <tr><td>工号</td><td><input type=text name=agntnum size=20></td></tr>
    <tr><td>密码</td><td><input type=password name="passwd"  size=20></td></tr>
    <tr><td colspan=2><input name=login type=submit value="进 入"></td>
        <td colspan=2><input name=reset type=reset value="取 消"></td>
    </tr>
    </table>
    </form>
      

  5.   

    第一种用法
    $_SERVER["PHP_SELF"]
    第二种用法
    php.ini中改
    register_globals = On$php_self
    <form method=POST NAME=$userlogin ACTION=<?$PHP_SELF?>>
      

  6.   

    也可这样
    echo "<form method=POST NAME=$userlogin ACTION=$PHP_SELF>";
      

  7.   

    1、<form method=POST NAME=<?=$userlogin ?> ACTION=<?=$SERVER['PHP_SELF'] ?>>
    2、既然有
    $agntnum=$_POST['agntnum'];
    $passwd =$_POST['passwd'];
    那么以后的$_POST['agntnum']和$_POST['passwd']就是多余的了
    直接用$agntnum、$passwd好了
      

  8.   

    我的PHP_SELF = /yx/index.php 
    运行环境是WIN2000+IIS5
    运行时http://192.168.1.1/yx/index.php
    我的FORM是<form method=POST NAME=userlogin ACTION==<? echo $PHP_SELF ?>>
    但是为什么提交表单时 URL=http://10.30.84.110/yx/=/yx/index.php,
      

  9.   

    用==不对,实际上那个FORM的HTML最终效果是:
    <FORM METHOD=POST NAME=userlogin ACTION==/yx/index.php>
    也就是说实际的ACTION是"=/yx/index.php"。去掉一个=号。
      

  10.   

    if($_POST['submit'])
    {
       如果正确
         处理
       如果错误
         处理
    exit;
    }
    <form name="form1" mothed="post" action="<?echo $PHP_SELF?>">
    <input type="text" name="user">
    <input type="password" name="password">
    <input type="buttion" value="提交" name="submit">
    直接写的可能有错,不过这样就不用跳转,而且也很保护传递参数,一定要有mothed,否则就不对了!