Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require '../config.php';
  4.  
  5. if (isset($_SESSION['user'])) {
  6. header("Location: ".$config['web']['url']);
  7. } else {
  8. if (isset($_POST['login'])) {
  9. $post_username = $conn->real_escape_string(trim(filter($_POST['username'])));
  10. $post_password = $conn->real_escape_string(trim(filter($_POST['password'])));
  11.  
  12. $check_user = $conn->query("SELECT * FROM users WHERE username = '$post_username'");
  13. $check_user_rows = mysqli_num_rows($check_user);
  14. $data_user = mysqli_fetch_assoc($check_user);
  15.  
  16. $verif_pass = password_verify($post_password, $data_user['password']);
  17.  
  18. if (!$post_username || !$post_password) {
  19. $_SESSION['hasil'] = array('alert' => 'danger', 'judul' => 'Gagal', 'pesan' => 'Harap Mengisi Input Pada Form <br /> - Username <br /> - Password.');
  20. } else if ($check_user_rows == 0) {
  21. $_SESSION['hasil'] = array('alert' => 'danger', 'judul' => 'Gagal', 'pesan' => 'Pengguna Tidak Tersedia.');
  22. } else if ($data_user['status'] == "Tidak Aktif") {
  23. $_SESSION['hasil'] = array('alert' => 'danger', 'judul' => 'Gagal', 'pesan' => 'Akun Sudah Tidak Aktif.');
  24. } else {
  25. if ($check_user_rows == 1){
  26. if ($verif_pass == true) {
  27. $conn->query("INSERT INTO log VALUES ('','$post_username', 'Login', '".get_client_ip()."','$date','$time')");
  28. $_SESSION['user'] = $data_user;
  29. $_SESSION['hasil'] = array('alert' => 'success', 'judul' => 'Berhasil Masuk!', 'pesan' => 'Selamat Datang <b>'.$data_user['username'].'</b>, Semoga Hari Anda Menyenangkan');
  30. exit(header("Location: ".$config['web']['url']));
  31. } else {
  32. $_SESSION['hasil'] = array('alert' => 'danger', 'judul' => 'Gagal', 'pesan' => 'Username atau password salah.');
  33. }
  34. }
  35. }
  36. }
  37. }
  38. require '../lib/header.php';
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement