daily pastebin goal
67%
SHARE
TWEET

Untitled

a guest May 16th, 2018 113 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function(){
  2.     $('#errorLogin').hide();
  3.     $('#formLogin').submit(function(e){
  4.         var username=$('#inputUser').val();
  5.         var password=$('#inputPassword').val();
  6.         $.ajax({
  7.             type:'get',
  8.             dataType: 'json',
  9.             url: 'dist/php/connection-login.php',
  10.             data: {
  11.                 user: username,
  12.                 pass: password
  13.             },
  14.             success: function(e){
  15.                 console.log(e);
  16.             }
  17.         });
  18.     });
  19. });
  20.    
  21. <?php
  22.  
  23.     $con = new mysqli("localhost", "root", "root", "solucionar_manutencoes_db");
  24.  
  25.     $lg_user=$_GET['user'];
  26.     $lg_password=$_GET['pass'];
  27.  
  28.     if (mysqli_connect_errno()) trigger_error(mysqli_connect_error());
  29.  
  30.     $qry = mysqli_query($con, "SELECT * FROM tb_login WHERE lg_user = '$lg_user' AND lg_password = '$lg_password';");    
  31.     $result = mysqli_fetch_assoc($qry);
  32.     $row = mysqli_fetch_assoc($result);
  33.  
  34.     if ($row != 0) {
  35.         $response["success"] = 1;
  36.         echo json_encode($response);
  37.     }
  38.     else {
  39.         $response["failed"] = 0;
  40.         echo json_encode($response);
  41.     }
  42. ?>
RAW Paste Data
Top