174 lines
6.5 KiB
PHP
174 lines
6.5 KiB
PHP
<?php
|
|
session_start();
|
|
?>
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>Login Admin</title>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
|
|
<!-- Fonts -->
|
|
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700&display=swap" rel="stylesheet">
|
|
|
|
<!-- Font Awesome -->
|
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
|
|
|
|
<!-- Custom CSS -->
|
|
<style>
|
|
body {
|
|
background: #FFFAE6;
|
|
font-family: 'Lato', sans-serif;
|
|
}
|
|
.login-wrap {
|
|
background: #FFD28F;
|
|
padding: 30px;
|
|
border-radius: 10px;
|
|
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
|
|
}
|
|
.form-control {
|
|
border: 2px solid #E6732A;
|
|
background: #FFF5E1;
|
|
color: #2F2F2F;
|
|
}
|
|
.form-control::placeholder {
|
|
color: #A65F23;
|
|
}
|
|
.btn-primary {
|
|
background-color: #FFA836 !important;
|
|
border-color: #E6732A !important;
|
|
color: white !important;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background-color: #E6732A !important;
|
|
border-color: #C15A1A !important;
|
|
}
|
|
.text-center a {
|
|
color: #E6732A;
|
|
}
|
|
.text-center a:hover {
|
|
color: #C15A1A;
|
|
}
|
|
.icon {
|
|
background: #E6732A;
|
|
color: white;
|
|
padding: 15px;
|
|
border-radius: 50%;
|
|
font-size: 24px;
|
|
width: 50px;
|
|
height: 50px;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
margin: auto;
|
|
}
|
|
</style>
|
|
|
|
<!-- Custom CSS -->
|
|
<link rel="stylesheet" href="css/style.css">
|
|
|
|
<!-- SweetAlert2 -->
|
|
<script src="../dist/sweetalert2.all.min.js"></script>
|
|
</head>
|
|
<body>
|
|
<section class="ftco-section">
|
|
<div class="container">
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-6 text-center mb-5">
|
|
<h2 class="heading-section">Login Admin</h2>
|
|
</div>
|
|
</div>
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-6 col-lg-5">
|
|
<div class="login-wrap">
|
|
<div class="icon">
|
|
<span class="fa fa-user-o"></span>
|
|
</div>
|
|
<h3 class="text-center mb-4">Masuk ke Panel Admin</h3>
|
|
|
|
<!-- Form Login -->
|
|
<form action="" method="POST" class="login-form">
|
|
<div class="form-group">
|
|
<input type="text" name="user" class="form-control rounded-left" placeholder="Username" required>
|
|
</div>
|
|
<div class="form-group d-flex">
|
|
<input type="password" name="pass" class="form-control rounded-left" placeholder="Password" required>
|
|
</div>
|
|
<div class="form-group d-md-flex">
|
|
<div class="w-50">
|
|
<label class="checkbox-wrap checkbox-primary">
|
|
Ingat Saya!
|
|
<input type="checkbox" name="remember" checked>
|
|
<span class="checkmark"></span>
|
|
</label>
|
|
</div>
|
|
<div class="w-50 text-md-right">
|
|
<a href="forgot_password.php">Lupa Password?</a>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<button type="submit" class="btn btn-primary rounded submit p-3 px-5" name="submit">Masuk</button>
|
|
</div>
|
|
</form>
|
|
|
|
<!-- PHP Login Script -->
|
|
<?php
|
|
if (isset($_POST['submit'])) {
|
|
include '../config.php';
|
|
|
|
$user = mysqli_real_escape_string($conn, $_POST['user']);
|
|
$pass = mysqli_real_escape_string($conn, $_POST['pass']);
|
|
|
|
// Query untuk cek admin
|
|
$cek_admin = mysqli_query($conn, "SELECT * FROM admin WHERE username = '$user'");
|
|
|
|
if (mysqli_num_rows($cek_admin) > 0) {
|
|
$d = mysqli_fetch_object($cek_admin);
|
|
|
|
if (password_verify($pass, $d->password)) {
|
|
$_SESSION['status_login'] = true;
|
|
$_SESSION['user_global_admin'] = $d;
|
|
$_SESSION['id_admin'] = $d->id;
|
|
|
|
echo "<script>
|
|
Swal.fire({
|
|
title: 'Login Berhasil!',
|
|
text: 'Selamat Datang {$d->nama_admin}!',
|
|
icon: 'success'
|
|
}).then(() => {
|
|
window.location = '../admin/index.php';
|
|
});
|
|
</script>";
|
|
} else {
|
|
echo "<script>
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Oops...',
|
|
text: 'Username atau Password Anda salah!',
|
|
}).then(() => {
|
|
window.location = '';
|
|
});
|
|
</script>";
|
|
}
|
|
} else {
|
|
echo "<script>
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Oops...',
|
|
text: 'Username atau Password Anda salah!',
|
|
}).then(() => {
|
|
window.location = '';
|
|
});
|
|
</script>";
|
|
}
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</body>
|
|
</html>
|