-
Notifications
You must be signed in to change notification settings - Fork 0
/
tambah_user.php
68 lines (61 loc) · 2.55 KB
/
tambah_user.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
<?php
session_start();
if (empty($_SESSION['username']) || empty($_SESSION['password'])) {
echo "<script>alert('Anda tidak memiliki akses'); window.location = 'login.php'</script>";
} else {
// Ambil level pengguna dari sesi
$level = $_SESSION['level'];
// Cek apakah pengguna adalah admin
if ($level !== 'admin') {
echo "<script>alert('Anda tidak memiliki akses'); window.location = 'dashboard.php'</script>";
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tambah User</title>
<link href="bootstrap-5.3.2-dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"
integrity="sha384-dvf8C79NIgIy5HDSnVc1PWWy4sy6cSN2fH3xKMEz1rBftNRLu1TII53QbQZJz5q24" crossorigin="anonymous">
<script src="bootstrap-5.3.2-dist/js/bootstrap.bundle.min.js"></script>
</head>
<body class="bg-light">
<div class="container-fluid">
<div class="row">
<div class="col-md-12 mb-4">
<?php include "menu.php"; ?>
</div>
</div>
<div class="card border-secondary mb-4">
<div class="card-header bg-secondary text-white">
<h4 class="m-0">Tambah User</h4>
</div>
<div class="card-body">
<form action="proses_tambah_user.php" method="POST">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="mb-3">
<label for="nama_lengkap" class="form-label">Nama Lengkap</label>
<input type="text" class="form-control" id="nama_lengkap" name="nama_lengkap" required>
</div>
<!-- Level diisi otomatis sebagai 'user' -->
<input type="hidden" name="level" value="user">
<button type="submit" class="btn btn-primary">Tambah User</button>
</form>
</div>
</div>
</div>
</body>
</html>
<?php
}
?>