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 如何让企业微信机器人实现消息汇总整合
    • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
    • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
    • ¥15 TLE9879QXA40 电机驱动
    • ¥20 对于工程问题的非线性数学模型进行线性化
    • ¥15 Mirare PLUS 进行密钥认证?(详解)
    • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
    • ¥20 想用ollama做一个自己的AI数据库
    • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
    • ¥15 请问怎么才能复现这样的图呀