Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- require '../config.php';
- if (isset($_SESSION['user'])) {
- header("Location: ".$config['web']['url']);
- } else {
- if (isset($_POST['login'])) {
- $post_username = $conn->real_escape_string(trim(filter($_POST['username'])));
- $post_password = $conn->real_escape_string(trim(filter($_POST['password'])));
- $check_user = $conn->query("SELECT * FROM users WHERE username = '$post_username'");
- $check_user_rows = mysqli_num_rows($check_user);
- $data_user = mysqli_fetch_assoc($check_user);
- $verif_pass = password_verify($post_password, $data_user['password']);
- if (!$post_username || !$post_password) {
- $_SESSION['hasil'] = array('alert' => 'danger', 'judul' => 'Gagal', 'pesan' => 'Harap Mengisi Input Pada Form <br /> - Username <br /> - Password.');
- } else if ($check_user_rows == 0) {
- $_SESSION['hasil'] = array('alert' => 'danger', 'judul' => 'Gagal', 'pesan' => 'Pengguna Tidak Tersedia.');
- } else if ($data_user['status'] == "Tidak Aktif") {
- $_SESSION['hasil'] = array('alert' => 'danger', 'judul' => 'Gagal', 'pesan' => 'Akun Sudah Tidak Aktif.');
- } else {
- if ($check_user_rows == 1){
- if ($verif_pass == true) {
- $conn->query("INSERT INTO log VALUES ('','$post_username', 'Login', '".get_client_ip()."','$date','$time')");
- $_SESSION['user'] = $data_user;
- $_SESSION['hasil'] = array('alert' => 'success', 'judul' => 'Berhasil Masuk!', 'pesan' => 'Selamat Datang <b>'.$data_user['username'].'</b>, Semoga Hari Anda Menyenangkan');
- exit(header("Location: ".$config['web']['url']));
- } else {
- $_SESSION['hasil'] = array('alert' => 'danger', 'judul' => 'Gagal', 'pesan' => 'Username atau password salah.');
- }
- }
- }
- }
- }
- require '../lib/header.php';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement