-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
56 lines (51 loc) · 2.21 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html lang="en">
<?php
include('components/koneksi.php');
$_SESSION['success'] = "";
$username = "";
if (isset($_POST['submit'])) {
session_start();
$username = mysqli_real_escape_string($koneksi, $_POST['username']);
$pass = mysqli_real_escape_string($koneksi, $_POST['password']);
$password = md5($pass);
$queryUser = mysqli_query($koneksi, "SELECT * FROM users WHERE username ='$username' AND password ='$password'");
$cekUser = mysqli_num_rows($queryUser);
$dataUser = mysqli_fetch_array($queryUser);
if ($cekUser == 0) {
echo "<script>alert('Username atau Password Anda salah. Silahkan coba lagi!')</script>";
} else if ($cekUser > 0) {
// Storing username in session variable
$_SESSION['id'] = $dataUser['id_admin'];
$_SESSION['username'] = $username;
$_SESSION['role'] = $dataUser['role'];
$_SESSION['success'] = "You have logged in!";
header('Location: pages/beranda.php');
}
}
?>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="Description" content="Enter your description here" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css">
<link rel="stylesheet" href="css/style.css">
<title>SPK Pemilihan Kualitas Madu</title>
</head>
<body>
<div class='container-login'>
<div class="box-login">
<h2>Login</h2>
<form action="" method="POST">
<input class="input-login" type="text" name="username" placeholder="Username">
<input class="input-login" type="password" name="password" placeholder="Password">
<input class="btn-submit" type="submit" name="submit" value="Masuk">
</form>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>