Advertisement
Guest User

Untitled

a guest
Sep 16th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. if (isset($_SESSION['username']))
  5. {
  6. header("Location: home.php");
  7. die();
  8. }
  9.  
  10. error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
  11. include 'koneksi.php';
  12.  
  13. $username = mysqli_real_escape_string($koneksi, $_POST['username']);
  14. $password = mysqli_real_escape_string($koneksi, $_POST['password']);
  15. $query = mysqli_query($koneksi, "SELECT * FROM tb_user WHERE username = '$username'");
  16.  
  17. if (mysqli_num_rows($query) == 0)
  18. {
  19. echo "<script>
  20. alert('Username atau Password Salah !!');
  21. document.location.href = 'login.php';
  22. </script>";
  23. }
  24. else
  25. {
  26. $data = mysqli_fetch_assoc($query);
  27. if ($password == $data['password'])
  28. {
  29. $_SESSION['username'] = $data['username'];
  30. $_SESSION['password'] = $data['password'];
  31. if ($data)
  32. {
  33. header("Location: home.php");
  34. }
  35. }
  36. else
  37. {
  38. echo "
  39. <script>
  40. alert('Username atau Password Salah !!');
  41. document.location.href = 'login.php';
  42. </script>";
  43. }
  44. }
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement