-
Notifications
You must be signed in to change notification settings - Fork 1
/
user_edit.php
181 lines (157 loc) · 6.19 KB
/
user_edit.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
175
176
177
178
179
180
181
<?php
//cek session
session_start();
require_once 'config/config.php';
if (empty($_SESSION['loggedin'])) {
header("Location: ./");
die();
} elseif ($_SESSION['level'] === 'Kasir') {
header("Location: ./home.php");
} else {
if (!isset($_GET['id_user'])) {
header('Location: user.php');
}
$id_user = $_GET['id_user'];
$sql = "SELECT * FROM tb_user WHERE id_user=$id_user";
$query = mysqli_query($db, $sql);
$user= mysqli_fetch_assoc($query);
if (mysqli_num_rows($query) < 1){
header("Location: user.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<?php include('_partials/head.php'); ?>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<?php include('_partials/navbar.php'); ?>
<?php include('_partials/sidebar.php'); ?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
User
<small>
</small>
</h1>
</section>
<!-- Main content -->
<section class="content">
<?php if (isset($_SESSION['error'])) : ?>
<p>
<?php
$error = $_SESSION['error'];
if ($error) {
?>
<div id="errorMessage" class="alert alert-danger" role="alert">
<i class="fa fa-exclamation-circle"></i> <?=$error;?>
</div>
<?php
}
?>
</p>
<?php
unset($_SESSION['error']);
endif;
?>
<div class="row">
<!-- left column -->
<div class="col-md-12">
<!-- general form elements -->
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">Edit Data User
<a class="btn btn-primary" href="user.php"><i class="fa fa-fw fa-arrow-left"></i> Kembali</a></h3>
</div>
<!-- /.box-header -->
<!-- form start -->
<form method="post" action="user_edit_process.php" role="form">
<input type="hidden" name="id_user" value="<?=$user['id_user'];?>" />
<div class="box-body">
<div class="form-group">
<div class="row">
<div class="col-md-5">
<label>Username</label>
<input type="text" class="form-control" placeholder="Username User" name="username" value="<?=$user['username'];?>" autofocus="autofocus" required="required">
<p class="help-block">Username minimal 6 karakter, tidak boleh mengandung spasi dan garis bawah di depan atau di belakang.</p>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-5">
<label>Nama</label>
<input type="text" class="form-control" placeholder="Nama user" name="nama_user" value="<?=$user['nama_user'];?>" required="required">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-5">
<label>Password</label>
<input type="password" class="form-control" placeholder="Password User" name="password" required="required">
<p class="help-block">Password minimal 8 karakter, mengandung setidaknya satu huruf kapital, satu nomor dan satu karakter khusus (!@#$%^&*-).</p>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-5">
<label>Konfirmasi Password</label>
<input type="password" class="form-control" placeholder="Konfirmasi Password User" name="k_password" required="required">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-4">
<label>Level</label>
<select class="form-control" name="level" required="">
<option value="<?=$user['level'];?>"><?=$user['level'];?></option>
<option value="Administrator">Administrator</option>
<option value="Kasir">Kasir</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-4">
<label>Status</label>
<select class="form-control" name="status" required="">
<option value="<?=$user['status'];?>"><?=$user['status'];?></option>
<option value="Aktif">Aktif</option>
<option value="Tidak Aktif">Tidak Aktif</option>
</select>
</div>
</div>
</div>
</div>
<!-- /.box-body -->
<div class="box-footer">
<input type="submit" value="Simpan Data" class="btn btn-success" name="simpan" />
<a class="btn btn-default" href="user.php">Batal</a>
</div>
</form>
</div>
<!-- /.box -->
</div>
<!-- /.col-lg-6 -->
</div>
<!-- /.row -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<?php include('_partials/footer.php'); ?>
</div>
<!-- ./wrapper -->
<?php include('_partials/modal.php'); ?>
<?php include('_partials/js.php'); ?>
<?php include('_partials/ajax.php'); ?>
</body>
</html>
<?php
}
?>