dtdr57046 2014-02-15 19:41 采纳率: 100%
浏览 32
已采纳

用户登录密码错误[关闭]

I am trying to create login system with access level but i the bellow code always shows please enter you password. please help me where i am wrong.

session_start();

if(isset($_REQUEST['submit'])) {
    $username=$_POST['username'];
    $mypassword=$_POST['password'];
    if($username){
        if($password){
        require('conn/iclude.php');
        $password=sha1($password);
        $query=mysql_query("SELECT * FROM admin where name='$username'");
        $numrow=mysql_num_rows($query);
            if($numrow==1){
                $row=mysql_fetch_assoc($query);
                $dbid=$row['id'];
                $dbuser=$row['name'];
                $dbpass=$row['pass'];
                $role=$row['role'];
                if($password==$dbpass) {
                    $_SESSION['username']=$dbuser;
                    $_SESSION['useridid']=$dbid;
                    if($role == 1){
                    header('Location:admin.php');
                    }elseif ($role==2) {
                    header('Location:1/neasp.php');
                    }elseif ($role==3) {
                    header('Location:2/index.php');
                    }elseif ($role==4) {
                    header('Location:3/index.php');
                    }elseif ($role==5) {
                    header('Location:4/index.php');
                    } 
                }else{}
            }else{
                echo"Hello World";
                }
        }else{echo "You must enter your password";}

    }else {echo "You must enter your name";}
}

thanks below is html form

  • 写回答

1条回答 默认 最新

  • dongyuans61046 2014-02-15 19:44
    关注
        $mypassword=$_POST['password'];
         ^^^^^^^^^^^  **MY** password
    
        if($password){
            ^^----no **MY**
    

    If your system was properly configured for debugging, e.g. display_errors and error_reporting turned on, you'd have gotten warnings about using undefined variables. A development/test system should *NEVER have these settings off in the first place.

    You are also vulnerable to SQL injection attacks. Enjoy having your server pwn3d.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教