DragonWar% 2017-06-11 14:25 采纳率: 0%
浏览 5

PHP不显示警报

I have a problem with the following code. According to him if in the place on username and we will enter data which are missing in the database on the password should show it oneself alert with information. Unfortunately if I will enter wrong data modal is disappearing and alert isn't being shown. I will be grateful for help.

<script> $(document).ready(function(){  
  $('#login_button').click(function(){  
       var username = $('#username').val();  
       var password = $('#password').val();  
       if(username != '' && password != '')  
       {  
            $.ajax({  
                 url:"action.php",  
                 method:"POST",  
                 data: {username:username, password:password},  
                 success:function(data)  
                 {  
                      //alert(data);  
                      if(data == 'No')  
                      {  
                           alert("Wrong Data");  
                      }  
                      else  
                      {  
                           $('#loginModal').hide();  
                           location.reload();  
                      }  
                 }  
            });  
       }  
       else  
       {  
            alert("Both Fields are required");  
       }  
  });  
  $('#logout').click(function(){  
       var action = "logout";  
       $.ajax({  
            url:"action.php",  
            method:"POST",  
            data:{action:action},  
            success:function()  
            {  
                 location.reload();  
            }  
       });  
  });   });  


AND Action.php

 <?php  
 session_start();  
 $connect = mysqli_connect("localhost", "root", "", "testing");  
 if(isset($_POST["username"]))  
 {  
      $query = "  
      SELECT * FROM admin_login  
      WHERE admin_name = '".$_POST["username"]."'  
      AND admin_password = '".$_POST["password"]."'  
      ";  
      $result = mysqli_query($connect, $query);  
      if(mysqli_num_rows($result) > 0)  
      {  
           $_SESSION['username'] = $_POST['username'];  
           echo 'Yes';  
      }  
      else  
      {  
           echo 'No';  
      }  
 }  
 if(isset($_POST["action"]))  
 {  
      unset($_SESSION["username"]);  
 }  
 ?>      
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 WPF 大屏看板表格背景图片设置
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示