-
Notifications
You must be signed in to change notification settings - Fork 2
/
setting.php
174 lines (151 loc) · 4.49 KB
/
setting.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
$basepath = true;
$data['title'] = "User Management";
$data['menu'] = 4;
$data['submenu'] = 41;
include "header.php";
if(isset($_POST['btn'])){
$user = $_POST['user'];
$email = $_POST['email'];
$name = $_POST['name'];
$pass1 = $_POST['pswd1'];
$pass2 = $_POST['pswd2'];
if(empty($user) or empty($name) or empty($email) or empty($pass1) or empty($pass2)){
create_alert("error","Mohon mengisi kolom yang sudah disediakan dengan lengkap.");
}
else{
$cek = query("SELECT * FROM skripsi_admin WHERE user = ".quote($user));
if($cek->rowCount() == 0){
//save
if($pass1 <> $pass2){
create_alert("error","Password yang dimasukkan tidak sama.");
}
else if(strlen($pass1) < 5){
create_alert("error","Password tidak aman. Gunakan minimal 5 karakter");
}
else{
$newpass = password_hash($pass2, PASSWORD_DEFAULT);
$sql = "INSERT INTO skripsi_admin VALUES (".quote($user).", ".quote($newpass).", ".quote($name).", ".quote($email).", 2);";
$ins = query($sql);
if($ins){
create_alert("Success","Berhasil menginput data pengguna","setting.php");
}
else{
create_alert("Error","Error SQL : $sql");
}
}
}
else{
//not save
create_alert("error","Username tersebut sudah ada, mohon gunakan username lain.");
}
}
}
?>
<br>
<h1>User Management</h1>
<br>
<div class="pmd-card pmd-z-depth">
<div class="pmd-tabs">
<div class="pmd-tab-active-bar"></div>
<ul class="nav nav-tabs nav-justified" role="tablist">
<li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Manage Users</a></li>
<li role="presentation"><a href="#about" aria-controls="about" role="tab" data-toggle="tab">New Users</a></li>
</ul>
</div>
<div class="pmd-card-body">
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">
<table class="data table pmd-table">
<thead>
<tr>
<th>#</th>
<th>Username</th>
<th>Name</th>
<th>Email</th>
<th>Priviledge</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$sql = query("SELECT * FROM skripsi_admin");
$no = 1;
foreach($sql as $row){
if($row['priviledge'] == 1){
$level = "Administrator";
$button = "<a href='update-setting.php?id=$row[user]' class='btn btn-primary pmd-ripple-effect'>Update</a>";
}
else if($row['priviledge'] ==2){
$level = "PJM Staff";
$button = "<a href='update-setting.php?id=$row[user]' class='btn btn-primary pmd-ripple-effect'>Update</a> <a href='crud/delete-user&id=$row[user]' class='btn btn-danger pmd-ripple-effect delete-button'>Hapus</a> ";
}
echo "
<tr>
<td>$no</td>
<td>$row[user]</td>
<td>$row[name]</td>
<td>$row[email]</td>
<td>$level</td>
<td>$button</td>
</tr>
";
$no++;
}
?>
</tbody>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="about">
<form action="" class="form-horizontal" method="post">
<div class="form-group">
<div class="form-group pmd-textfield">
<label for="user" class="control-label">
Username
</label>
<input type="text" name="user" id="user" class="form-control" >
</div>
</div>
<div class="form-group">
<div class="form-group pmd-textfield">
<label for="name" class="control-label">
Name
</label>
<input type="text" name="name" id="name" class="form-control" >
</div>
</div>
<div class="form-group">
<div class="form-group pmd-textfield">
<label for="email" class="control-label">
Email
</label>
<input type="text" name="email" id="email" class="form-control" >
</div>
</div>
<div class="form-group">
<div class="form-group pmd-textfield">
<label for="pswd1" class="control-label">
Password
</label>
<input type="password" name="pswd1" id="pswd1" class="form-control">
</div>
</div>
<div class="form-group">
<div class="form-group pmd-textfield">
<label for="pswd2" class="control-label">
Repeat Password
</label>
<input type="password" name="pswd2" id="pswd2" class="form-control">
</div>
</div>
<div>
<button name="btn" class="btn btn-primary btn-lg pmd-ripple-effect">Simpan User</button>
</div>
</form>
</div>
</div>
</div>
</div>
<?php
include "footer.php";
?>