-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·144 lines (143 loc) · 8.19 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
include("pages/koneksi.php");
session_start();
if(isset($_SESSION['user'])) {
echo "<script>window.location='home.php';</script>";
}
?>
<!-- ================================================== -->
<!DOCTYPE html>
<html dir="ltr" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="SPK Miftahussalam Banyumas">
<meta name="author" content="SPK Miftahussalam Banyumas">
<link rel="icon" type="image/png" sizes="16x16" href="assets/images/logo.png">
<link href="assets/dist/css/style.min.css" rel="stylesheet">
<title>SPK Miftahussalam Banyumas</title>
</head>
<!-- ================================================== -->
<body>
<div class="main-wrapper">
<div class="auth-wrapper d-flex justify-content-center align-items-center position-relative"
style="background:url(assets/images/background.png) no-repeat center center;">
<!-- Form Login -->
<div class="col-lg-3 col-md-3 bg-white">
<div class="p-5">
<div class="text-center">
<img src="assets/images/logo.png" alt="wrapkit">
</div>
<h2 class="mt-3 text-center">SPK Miftahussalam</h2>
<form action="" method="post">
<div class="input">
<div class="card-body">
<div class="col-lg-12">
<div class="form-group">
<input class="form-control" type="text" name="username" placeholder="Username" required autofocus>
</div>
</div>
<div class="col-lg-12">
<div class="form-group">
<input class="form-control" type="password" name="password" placeholder="Password" required autofocus>
</div>
</div>
<div class="col-lg-12">
<button class="btn btn-block btn-primary" type="submit" name="login">Masuk</button>
<button class="btn btn-block btn-success" type="button" data-toggle="modal" data-target="#register">Daftar akun baru</button>
</div>
</div>
</div>
</form>
</div>
</div>
<!-- Form Register -->
<div id="register" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="tambahModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header modal-colored-header bg-primary">
<h3 class="modal-title" id="tambahModalLabel">Registrasi</h3>
<button type="button" class="close" data-dismiss="modal">x</button>
</div>
<div class="col-lg-12 col-md-12 bg-white">
<div class="p-5">
<div class="text-center">
<img src="assets/images/logo.png" alt="wrapkit">
</div>
<h2 class="mt-3 text-center">SPK Miftahussalam</h2>
<form action="" method="post">
<div class="input">
<div class="card-body">
<div class="col-lg-12">
<div class="form-group">
<input class="form-control" type="text" name="nama" placeholder="Nama" required autofocus>
</div>
</div>
<div class="col-lg-12">
<div class="form-group">
<input class="form-control" type="text" name="username" placeholder="Username" required autofocus>
</div>
</div>
<div class="col-lg-12">
<div class="form-group">
<input class="form-control" type="password" name="password" placeholder="Password" required autofocus>
</div>
</div>
<div class="modal-footer">
<div class="col-lg-12">
<button class="btn btn-block btn-success" type="submit" name="register">Daftar</button>
</div>
</div>
</div>
</div>
</form>
<!-- Config Login -->
<?php
if(isset($_POST['login'])) {
$username = $_POST['username'];
$password = md5($_POST['password']);
$query = "SELECT * FROM user WHERE username='$username' AND password='$password'";
$hasil = mysqli_query($koneksi, $query);
if(mysqli_num_rows($hasil) > 0) {
$_SESSION['user'] = $username;
echo "<script>window.location='home.php';</script>";
} else {
echo "<script>alert('Login gagal! Coba ulangi lagi');</script>";
}
}
?>
<!-- Config Register -->
<?php
if(isset($_POST['register'])) {
$nama = $_POST['nama'];
$username = $_POST['username'];
$password = md5($_POST['password']);
$query = "INSERT INTO user (nama, username, password)
VALUES ('$nama', '$username', '$password')";
$register = mysqli_query($koneksi, $query);
if($register > 0) {
echo "<script>alert('Registrasi sukses!');
window.location='index.php';</script>";
} else {
echo "<script>alert('Registrasi gagal! Coba ulangi lagi');</script>";
}
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="assets/libs/jquery/dist/jquery.min.js "></script>
<script src="assets/libs/popper.js/dist/umd/popper.min.js "></script>
<script src="assets/libs/bootstrap/dist/js/bootstrap.min.js "></script>
<script>
$(".preloader ").fadeOut();
</script>
</body>
<!-- ================================================== -->
</html>
<!-- Developt by https://www.facebook.com/Vickry.ID -->