-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
77 lines (67 loc) · 2.5 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
session_start();
include './process/koneksi.php';
if (isset($_GET['id'])) {
if ($_GET['id'] == 'false') {
echo "<script>alert('username / password salah. Gagal masuk.')</script>";
header("location:login.php");
} else if ($_GET['id'] == 'out') {
echo "<script>alert('Anda belum masuk, silahkan maasuk.')</script>";
header("location:login.php");
} else {
echo "<script>alert('Logout berhasil.')</script>";
header("location:login.php");
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sistem Pendukung Keputusan</title>
<link rel="stylesheet" href="./css/login.css" />
</head>
<body>
<div class="login-container">
<center>
<img src="./images/logo1.png" alt="logo" style="height: 170px;">
</center>
<div class="login-box">
<h1>SISTEM PENDUKUNG KEPUTUSAN</h1>
<p>
Pemilihan Karyawan Terbaik Menggunakan Metode Weight Product (WP)
</p>
<form method="POST" role="form">
<div class="input-group">
<input type="text" id="username" name="username" placeholder="Username" required />
</div>
<div class="input-group">
<input type="password" id="password" name="password" placeholder="Password" required />
</div>
<button type="submit" name="submit" value="Masuk">Login</button>
</form>
<?php
if (isset($_POST['submit'])) {
$username = mysqli_real_escape_string($connect, $_POST['username']);
$password = mysqli_real_escape_string($connect, $_POST['password']);
$sqllogin = "SELECT * FROM pengguna WHERE username='$username' AND password='$password'";
$querylogin = mysqli_query($connect, $sqllogin);
if (mysqli_num_rows($querylogin) > 0) {
$row = mysqli_fetch_assoc($querylogin);
$_SESSION['username'] = $username;
$_SESSION['nama'] = $row['nama'];
$_SESSION['level'] = $row['level'];
$_SESSION['stat'] = 'masuk';
echo "<script>alert('Berhasil masuk, selamat datang " . $row['nama'] . "')</script>";
header("location:landing-page.php");
exit;
} else {
echo "<script>alert('Username/password salah')</script>";
}
}
?>
</div>
</div>
</body>
</html>