为什么不管输入什么,每次都是跳转到http://localhost这个页面?<body>
<div align="center" class="STYLE1">
  <p>&nbsp;</p>
  <p>管理员登陆</p>
</div>
<form  name="form1" method="post" action = " ">
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center"><span class="STYLE2"><strong>管理员姓名</strong>:</span>
  <input type="text" name="ad_name" />   
</p>
<p align="center">&nbsp;</p>
<p align="center"><span class="STYLE2">密码:</span> 
  <input type="password" name="ad_password" />  
</p>
<p align="center">&nbsp;</p>
<p align="center"><input type="submit" name="Submit" value="确定" /><input type="reset" name="Submit2" value="重置" /> </p>
</form>
<?php
  if($_POST["Submit"]){
   $name=$_POST["ad_name"];
   $password=$_POST["ad_password"];
   
   mysql_connect("localhost","root","ps") or
   die("Could not connect:".mysql.error());
   mysql_select_db("library");
   $result=mysql_query("SELECT * FROM administrator WHERE ad_name='".$name."' and   
  ad_password='".$password."'");
   $numrow=mysql_num_rows($result);
   if($numrow<>0){
    header("location:./welcome.html"); //    跳到管理员可以处理的界面
   }
   else{
    header("location:./login.php");
   }
   mysql_close();
 }
?><br />

解决方案 »

  1.   

    大概看了一下,if($_POST["Submit"]),这个判断永远为假吧。你可以判断$_POST["ad_name"】或者$_POST["ad_password"】是否为空试试。
      

  2.   

    试试
    if($_POST["Submit"]==$_POST["ad_password" and $_POST["ad_user")
      

  3.   

    if($numrow<>0){
      header("Location: ./welcome.html"); // 跳到管理员可以处理的界面
      }
      else{
      header("Location: ./login.php");
      }
    注意空格。
      

  4.   

    请问下http://localhost页面时哪个页面啊
      

  5.   

    不会是你的.htacccess之类的东西配置的吧,可以查查配置
      

  6.   


    <body>
    <?php
      if($_POST["Submit"]==""){
    ?>
    <div align="center" class="STYLE1">
      <p>&nbsp;</p>
      <p>管理员登陆</p>
    </div>
    <form name="form1" method="post" action = " ">
    <p align="center">&nbsp;</p>
    <p align="center">&nbsp;</p>
    <p align="center"><span class="STYLE2"><strong>管理员姓名</strong>:</span> 
      <input type="text" name="ad_name" />   
    </p>
    <p align="center">&nbsp;</p>
    <p align="center"><span class="STYLE2">密码:</span>  
      <input type="password" name="ad_password" />   
    </p>
    <p align="center">&nbsp;</p>
    <p align="center"><input type="submit" name="Submit" value="确定" /><input type="reset"  name="Submit2" value="重置" /> </p>
    </form>
    <?PHP
    }ELSE{
      $name=$_POST["ad_name"];
      $password=$_POST["ad_password"];
        
      mysql_connect("localhost","root","ps") or
      die("Could not connect:".mysql.error());
      mysql_select_db("library");
      $result=mysql_query("SELECT * FROM administrator WHERE ad_name='".$name."' and   
      ad_password='".$password."'");
      $numrow=mysql_num_rows($result);
      if($numrow<>0){
      header("location:./welcome.html"); // 跳到管理员可以处理的界面
      }
      else{
      header("location:./login.php");
      }
      mysql_close();
     }
    ?><br />
      

  7.   

    还要把
    <form name="form1" method="post" action = " ">
    改成
    <form name="form1" method="post" action = "?">
      

  8.   


    mysql_select_db("library");
      $result=mysql_query("SELECT * FROM administrator WHERE ad_name='".$name."' and   
      ad_password='".$password."'");
    这两句对调一下,并把mysql_select_db("library")改成mysql_select_db("library",$result)
      

  9.   

    感觉你写的代码有些随意!不好的习惯容易造成各种BUG
      

  10.   

    楼上的太对了if($_POST["Submit"]),这个判断永远为假,我遇到过这类的问题我一直想写出好质量的代码来。。也一直在学习中。呵呵
      

  11.   

    为什么为假啊? 不是有值吗? <input type="submit" name="Submit" value="确定" /> 会提交过来"确定"这个值哦