dongshen6060 2016-04-29 07:45
浏览 25
已采纳

无法检查我的登录信息

I need to check whether the username and password inputted by the user is correct so they can log in. If it's correct, it will run a line of codes from the javascript code, if not, it will just alert that username/password is wrong. The problem is, the page just refreshes, it doesn't run the javascript code even if the username & password is right and also this appears:

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in D:\xampp\htdocs\statistics\index.php on line 195

(The error above is fixed, the only one not working now is the javascript code)

Here is my PHP code for the log in:

        if(isset($_POST['proceedToLogin'])) {
            if((!empty($_POST['username'])) && (!empty($_POST['password']))) {
               $uname = $_POST['username'];
               $pword = $_POST['password'];
               $selup = "SELECT * admin WHERE Username ='$uname'AND Password ='$pword'";
               $checkup = mysqli_query($conn, $selup);
                 if(mysqli_num_rows($checkup) > 0) {
                    print '<script type="text/javascript">';
                    print 'goHome(1);';
                    print 'return false;';
                    print '</script>';
                 }
            }
        }

the javascript code that's supposed to run:

function goHome(source){
            $('#bluearrow').css('margin-left','-100px');
            $('#orangearrow').css('margin-left','-200px');
            $('#greenarrow').css('margin-left','-300px');
            $('#grayarrow').css('margin-left','-400px');

            $("body").css("overflow","hidden");
            if(source == 1)
            $('#login').animate({ opacity: 'hide',  left: '-200px', }, 'slow', 'linear', function() {
                document.getElementById('username').value ="";
                document.getElementById('password').value ="";
                $("#login").hide();
                $("#login").css('margin-left', '280px');
            });
            else if(source == 2)
            $('#addApplicant').animate({ opacity: 'hide',  left: '-200px', }, 'slow', 'linear', function() {
                $(this).hide();
                $(this).css('left','30px');
            });

            $("#menu").hide().show();
            $("#bluearrow").hide();
            $("#orangearrow").hide();
            $("#greenarrow").hide();
            $("#grayarrow").hide();
            $(".menu-label").hide();
            $('html,body').scrollTop(0);

            setTimeout(function(){
                $("#bluearrow").hide().show("slide", { direction: "left" }, 1500);
            },500); 
            setTimeout(function(){
                $("#orangearrow").hide().show("slide", { direction: "left" }, 1500);
            },1300); 
            setTimeout(function(){
                $("#greenarrow").hide().show("slide", { direction: "left" }, 1500);
            },2000); 
            setTimeout(function(){
                $("#grayarrow").hide().show("slide", { direction: "left" }, 1500);
            },2700); 
            setTimeout(function(){
                $('span').animate({ opacity: 'show',  left: '50px', }, 'slow', 'linear', function() {
                $(this).show();
            });
            },4100); 
    }

They're both in the same file, btw.

  • 写回答

2条回答 默认 最新

  • douruobokui58233 2016-04-29 08:01
    关注

    Replace:

    $selup = "SELECT * admin WHERE Username ='$uname'AND Password ='$pword'";
    

    AND

     print '<script type="text/javascript">';
                        print 'goHome(1);';
                        print 'return false;';
                        print '</script>';
    

    With

    $selup = "SELECT * from admin WHERE Username ='$uname'AND Password '$pword'";
    

    AND

    print '<script type="text/javascript">';
    print '$(document).ready(function(){';
                        print 'goHome(1);';
                        print '});';
                        print '</script>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里