Advertisement
rijal9

cek_login

Mar 27th, 2017
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. <?php
  2. include ('../config/koneksi.php');
  3.  
  4. $user = $_POST['username'];
  5. $pass = MD5($_POST['password']);
  6. //------ANTI XSS & SQL INJECTION-------//
  7.  
  8. $login=mysqli_query($konek, "select * from admin where username='$user' and password='$pass' and blokir='N'");
  9. $r=mysqli_fetch_array($login);
  10. $ketemu = mysqli_num_rows($login);
  11. if ($ketemu > 0)
  12. {
  13. session_start();
  14. $_SESSION['username']=$r['username'];
  15. $_SESSION['password']=$r['password'];
  16.  
  17. echo "<script>alert('Login berhasil, silahkan masuk.');
  18. window.location = 'media.php?page=dashboard'</script>";
  19. }
  20. else
  21. {
  22. echo "<script>alert('Maaf! Login gagal. Anda tidak berhak mengakses halaman administrator.');
  23. window.location = 'index.php?page=auth'</script>";
  24. }
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement