$str="select * from user";should be 
$str="select * from user where user_name='$user'";晕,你一个问题都发了三遍了....

解决方案 »

  1.   

    (!(md5($password)===$row["user_password"]))
      

  2.   

    $str="select * from user where user_name = '$name'";
    $url="Location: main.php?userid=".$user_id;
      

  3.   

    俺来恶搞!!!嘿嘿。
    /****************/
    check-index.php
    /****************/<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>CHECKUSER</title>
    </head>
    <body>
    <?
    switch($title){
    case 1:
    ?><p><br><br><center>用户注册</center></p>
    <form action="check-adduser.php" method="post">
    <table width="400" border="1" align="center">
      <tr>
        <td width="150" align="center">姓名</td>
        <td width="250" align="center"><input name="username" type="text" size="20" maxlength="20"></td>
      </tr>
      <tr>
        <td align="center">密码</td>
        <td align="center"><input name="password" type="password" size="20" maxlength="20"></td>
      </tr>
      <tr>
        <td align="center">&nbsp;</td>
        <td align="right"><input name="" type="submit" value="注册"><input name="" type="reset"></td>
      </tr>
      <tr>
        <td align="center">&nbsp;</td>
        <td align="center"><a href="check-index.php">返回</a></td>
      </tr>
    </table>
    </form>
    <?
    break;
    case 2:
    ?>
    <p><br><br><center>用户登陆</center></p>
    <form action="check-check.php" method="post">
    <table width="400" border="1" align="center">
      <tr>
        <td width="150" align="center">姓名</td>
        <td width="250" align="center"><input name="username" type="text" size="20" maxlength="20"></td>
      </tr>
      <tr>
        <td align="center">密码</td>
        <td align="center"><input name="password" type="password" size="20" maxlength="20"></td>
      </tr>
      <tr>
        <td align="center">&nbsp;</td>
        <td align="right"><input name="" type="submit" value="登陆"><input name="" type="reset"></td>
      </tr>
      <tr>
        <td align="center">&nbsp;</td>
        <td align="center"><a href="check-index.php">返回</a></td>
      </tr>
    </table>
    </form>
    <?
    break;
    default:
    ?><br>
    <br>
    <table width="500" border="1" align="center">
      <tr>
        <td align="center"><a href="check-index.php?title=1">注册用户</a></td>
        <td align="center"><a href="check-index.php?title=2">用户登陆</a></td>
      </tr>
    </table><?
    break;
    }
    ?>
    </body>
    </html>/********************************//****************/
    check-adduser.php
    /****************/<?phpinclude("conn.php");$username=$HTTP_POST_VARS[username];
    $password=$HTTP_POST_VARS[password];if (empty($username) || empty($password)){
    die("Incomplete form");}$connect=mysql_pconnect($host,$dbusername,$dbpassword);
    mysql_select_db($database) or die("conn db error");$str="select * from user where username = '$username'";
    $result=mysql_query($str);if($row=mysql_fetch_array($result)){
    die("This name is been used!");}else{ $password = md5($password);
    $query="insert into user set username = '$username',password = '$password'";
    mysql_query($query) or die("add data error!");}echo "<HTML>";
    echo "<CENTER><BR><BR>regist successfully!</CENTER>";
    echo "<META http-equiv=\"refresh\" content =\"2;url=check-index.php\">";
    echo "</HTML>";
    exit;?>/**************************************//****************/
    check-check.php
    /****************/<?phpinclude("conn.php");$username=$HTTP_POST_VARS[username];
    $password=$HTTP_POST_VARS[password];if (empty($username) || empty($password)){
    die("Incomplete form");}$connect=mysql_pconnect($host,$dbusername,$dbpassword);
    mysql_select_db($database) or die("conn db error");$str="select * from user where username = '$username'";
    $result=mysql_query($str);if($row=mysql_fetch_array($result)){
    if (!(md5($password)===$row["password"])){
    die("Invalid Password"); } $userid=$row["userid"];}else{
    die("User does not exist !"); }$url="Location: check-main.php?userid=".$userid;
    header($url);
    exit;?>
    /***************************//****************/
    conn.php
    /****************/<?php
    $database="test";
    $host="localhost";
    $dbusername="root";
    $dbpassword="";?>
      

  4.   

    if (!(md5($password)===$row["password"]))
    每次程序执行到这个就出错,本来我的密码是和数据库密码是一样的,但是它老是提示
    die("Invalid Password"),这是为什么呢,我的password字段是字符型的,用户名可以判断得好,就是密码判断不出,为什么呢,是不是这个if语句有什么问题呢?
      

  5.   

    俺的表字段如下:userid int 11 auto_increment primary
                    username var 20
                    password var 60 (注意这里。太少了可不行哦:)
      

  6.   

    密码验证的问题我通过编程解决了,我不使用md5这个函数了,我先定义一个变量,然后把表里的password的值赋给定义的变量,然后再做比较就可以了,现在我继续来研究用户注册的问题,在这里我特别感谢 yh801216(艾奥利斯) 的帮忙.
      

  7.   

    yh801216(艾奥利斯):
    <?
    switch($title){
    case 1:
    ?>
    用这个case语句是用来判断什么的呢?
    是不是用来判断用户的级别??
    你一般什么时候在线呢,我想向你请教,我一般是晚上才有空,因为白天都要上课,现在我也是在上课,不过是上机课,今晚要下班辅导.希望辅导后能在网上见到你,
      

  8.   

    当我调用check-check.php的时候,不做任何操作,只显示一个空白页面,为什么会这样呢,我也找不出程序哪里出错,那个用户注册程序,已经可以注册了,但是当我添加一个密码确认,修改了一下check-adduser.php程序后,点链接到该程序后,也是显示一个空白页面,我也不知道是哪里出错.