本帖最后由 u011432403 于 2014-06-01 23:13:54 编辑

解决方案 »

  1.   

    你需要先判断下当前操作,也就是检测是否做提交处理,加上if(isset($_POST['submit'])) 
      

  2.   

    admin.php只有3行?报错的可是12行啊。
      

  3.   

    用你的程序测试了,有些空格并不是空格。修改后如下。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>用户登录</title>
      <style type="text/css">
        html{font-size:12px;}
        fieldset{width:300px; margin: auto;}
        legend{font-weight:bold; font-size:14px;}
        .label{float:left; width:55px; margin-left:10px;}
        .left{margin-left:120px;}
        .input{width:150px;}
        span{color: #666666;}
      </style>
    <script language=JavaScript>
     
    <!--
     
    function InputCheck(LoginForm)
    {
      if (LoginForm.name.value == "")
      {
        alert("请输入用户名!");
        LoginForm.name.focus();
        return (false);
      }
      if (LoginForm.password.value == "")
      {
        alert("请输入用户密码!");
        LoginForm.password.focus();
        return (false);
      }
    }
     
    //-->
    </script>
    </head>
    <body>
    <div>
    <fieldset>
    <legend>用户登录</legend>
    <form name="LoginForm" method="post" action="admin.php" onSubmit="return InputCheck(this)">
    <p>
    <label for="name" class="label">用户名:</label>
    <input id="name" name="name" type="text" class="input" />
    <p/>
    <p>
    <label for="password" class="label">用户密码:</label>
    <input id="password" name="password" type="password" class="input" />
    <p/>
    <p>
    <input type="submit" name="submit" value="  确 定  " class="left" />
    </p>
    </form>
    </fieldset>
    </div>
    </body>
    </html><?php
        $name = $_POST['name'];
        $password = $_POST['password'];
        echo $name,$password;
    ?>
    测试正常:
      

  4.   

     $name = isset($_POST['name']) ? $_POST['name'] : '';
        $password = isset($_POST['password']) ? $_POST['password'] : '';
        echo $name,$password;
      

  5.   

    onSubmit="return InputCheck(this)" 去掉试试