我只写出一段较为简单的代码~~其他的楼主自己看着办吧.....//这两个是变量,我采用的是post方法获取变量值,楼主可以选择其他方式
$name=$_POST[$username];
$pasw=$_POST[$password];$sql="select * from user where Username='$name' and Password='$pasw'";
$rs=mysql_query($sql);
$reccount=mysql_num_rows($rs);
if($reccount<>0){
  header("Location: index.php");//这里是跳去你的网站主页或其他你想跳去的页面
}以上只供参考~~当然这几个语句并不是最好的...可能存在问题~如果有问题大家可以提出来...楼主可以根据我给的大概思路来实现...登录界面很容易实现的..

解决方案 »

  1.   

    $sql = "select * from tab_name where Username = '".trim($_POST['username']."'");$re = mysql_query($sql);$r = @extract(mysql_fetch_array($re));if ($_POST['Password'] && $_POST['Password'] == $password) {
    登陆成功
    } else  {
    登陆失败
    }思路就这样的
      

  2.   

    这是我写的代码!输入以后没有反应!请各位提一下那里错误!
    <?php
    $conn = new com("adodb.connection");  
    $connstr="Provider=OraOLEDB.Oracle.1;Password=SZS;Persist Security Info=True;User ID=SZS;Data Source= oraDP;Extended Properties=''";
    $conn->open($connstr);
    ?><?php
    $sql="select * from SZSUser";
    $rs=new com("adodb.recordset");
    $rs->open($sql,$conn,1,3);
    ?>
    <?php
    if($_POST['login']){
      $sql="select * from SZSUser where Username={$_POST['Username']} and Password={$_POST['Password']}";
      $userInfo = &$_conn->GetRow($sql); //adodb
      if($userInfo){
         Header( "Location:./caky.php" );
    exit;
       }else{
         Header( "Location:./login.php" );
      }
    }
    ?>
     <!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=gb2312" />
    <title>登录界面</title>
    <style type="text/css">
    <!--
    .STYLE2 {color: #0033FF; font-weight: bold; font-family: "宋体"; font-size: xx-large;}
    -->
    </style>
    </head><body>
    <form method="post">
    <p align="center" class="STYLE2">系统登录</p>
    <table width=500 border=1 cellspacing=0 cellpadding=0 bgcolor=#8888ff bordercolor=#448844 align=center><tr><td>用户名称:</td>
    <td><INPUT id=txtName name="txtName"   style  ="WIDTH: 200px" tabindex="1" 
         ></td></tr><tr><td>用户密码:</td>
    <td><INPUT id=txtPwd name="txtPwd" type=password  style  ="WIDTH: 200px" tabindex="2" ></td></tr></table>
    <div align="left"></div>
    <p align="center">
      <label>
      <input type="submit" name="Submit" style   ="HEIGHT: 24px; WIDTH: 100px" tabindex="2" value="登录" />
      <input type="submit" name="Submit" style   ="HEIGHT: 24px; WIDTH: 100px" tabindex="2" value="取消" />
      </label>
    </form>
    </body>
    </html>
      

  3.   

    我发先两个问题1:$sql="select * from SZSUser where Username={$_POST['Username']} and Password={$_POST['Password']}"; 
      应该是 $sql="select * from SZSUser where Username='{$_POST['Username']}' and Password='{$_POST['Password']}'"; 
      
    2:<INPUT id=txtName name="txtName"  style  ="WIDTH: 200px" tabindex="1" >名字是txtName可是你Username={$_POST['Username']} 先改了再说把
      

  4.   

    <INPUT id=txtName name="txtName" 
    {$_POST['Username']}
    要相对应,
    要么就是{$_POST['txtName']}
    密码也一样
      

  5.   

    <?php
    //引用文件
    //require_once('./config.inc.php');$conn = new com("adodb.connection");  
    $connstr="Provider=OraOLEDB.Oracle.1;Password=SZS;Persist Security Info=True;User ID=SZS;Data Source= oraDP;Extended Properties=''";
    $conn->open($connstr);$sql="select * from SZSUser";
    $rs=new com("adodb.recordset");
    $rs->open($sql,$conn,1,3);
    if($_POST['login']){
      $sql="select * from SZSUser where Username={$_POST['txtName']} and Password={$_POST['txtPwd']}";
      $userInfo = &$_conn->GetRow($sql); //adodb
      if($userInfo){
         Header( "Location:./caky.php" );
    exit;
       }else{
         Header( "Location:./curve.php" );
      }
    }
    ?>
     <!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=gb2312" />
    <title>登录界面</title>
    <style type="text/css">
    <!--
    .STYLE2 {color: #0033FF; font-weight: bold; font-family: "宋体"; font-size: xx-large;}
    -->
    </style>
    </head><body>
    <form method="post">
    <p align="center" class="STYLE2">系统登录</p>
    <table width=500 border=1 cellspacing=0 cellpadding=0 bgcolor=#8888ff bordercolor=#448844 align=center><tr><td>用户名称:</td>
    <td><INPUT id=txtName name="txtName"   style  ="WIDTH: 200px" tabindex="1" ></td></tr><tr><td>用户密码:</td>
    <td><INPUT id=txtPwd name="txtPwd" type=password  style  ="WIDTH: 200px" tabindex="2" ></td></tr></table>
    <div align="left"></div>
    <p align="center">
      <label>
      <input type="submit" name="login" style   ="HEIGHT: 24px; WIDTH: 100px" tabindex="2" value="登录" />
      <input type="submit" name="Submit" style   ="HEIGHT: 24px; WIDTH: 100px" tabindex="2" value="取消" />
      </label>
    </form>
    </body>
    </html>
    已经对应!但是他们提示:"Fatal error: Call to a member function GetRow() on a non-object in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\index1.php on line 16
    "错误!
      

  6.   

    很明显啊你new 一个adodb对象是$conn
    但是你用的时候又&$_conn->GetRow($sql); //adodb $_conn怎么来的啊?因该是$conn->GetRow把?
      

  7.   

    楼上的我按照你说的改了,提示:"Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> ADODB.Connection<br/><b>Description:</b> 参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。' in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\index1.php:16 Stack trace: #0 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\index1.php(16): com->GetRow('select * from S...') #1 {main} thrown in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\index1.php on line 16
    "
      

  8.   

    $sql="select * from SZSUser where Username='{$_POST['txtName']}' and Password='{$_POST['txtPwd']}'"; 
    带上单引号试试。
    再不行,echo $sql; 看看sql写的对吗。