Guest User

Untitled

a guest
Aug 18th, 2018
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. <script type="text/javascript">
  2.     $(document).ready(function(){
  3.         $('#note').hide();
  4.         $('form[name=login]').submit(function(){
  5.             $('#note').slideUp();
  6.             $.post('login.php',{username: $('[name=username]').val(), password: $('[name=password]').val()}, function(data){
  7.                 if(data.success){
  8.                     location.href = data.redirect;
  9.                 }else{
  10.                     $('#note').html(data.message).slideDown();
  11.                 }
  12.             },'json');
  13.            
  14.             return false;
  15.         });
  16.     });
  17.    
  18. </script>
  19.  
  20.  
  21. //--------------------------- login.php ----------------------------------
  22.  
  23. <?php
  24.  
  25.  include ("scripts/database.php");
  26.  session_start();
  27.  
  28.  $username = mysql_real_escape_string($_POST['username']);
  29.  $password = mysql_real_escape_string($_POST['password']);
  30.  
  31.  $query  = new query("SELECT * FROM admin WHERE Username ='$username' and Password='$password' LIMIT 1");
  32.  $rows = $query->rows();
  33.  
  34.  if ($rows == 1) {
  35.     $data['success'] = true;
  36.     $_SESSION['adminID'] = $result['ID'];
  37.     $data['redirect'] = '/OGBI/admin/index.php';
  38.     //header("location:/OGBI/admin/");
  39.  }else{
  40.     $data['success'] = false;
  41.     $data['message']="Invalid Username and Password !";
  42.  }
  43.  
  44.  echo json_encode($data);
  45.  
  46.  
  47. ?>
Add Comment
Please, Sign In to add comment