-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuser.add.php
More file actions
67 lines (60 loc) · 2.88 KB
/
user.add.php
File metadata and controls
67 lines (60 loc) · 2.88 KB
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
<?php include('./template/head.php') ?>
<?php include('./php/connection.php') ?>
<?php
if (isset($_REQUEST['tambah'])) {
$nama_lengkap = mysqli_real_escape_string($connection, trim($_REQUEST['nama_lengkap']));
$username = mysqli_real_escape_string($connection, trim($_REQUEST['username']));
$kata_sandi = mysqli_real_escape_string($connection, trim($_REQUEST['kata_sandi']));
$sql = "INSERT INTO pengguna (
nama_lengkap,
username,
kata_sandi
)
VALUES (
'$nama_lengkap',
'$username',
'$kata_sandi'
)
;";
$query = mysqli_query($connection, $sql);
if ($query) { // success
echo "<script>
window.alert('Berhasil menambah data konsumen')
window.location.href = './user.php'
</script>";
} else { // error
echo "<script>
window.alert('Gagal menambah data konsumen. Terjadi kesalahan sistem')
</script>";
}
}
?>
<div class="container pt-5">
<div class="card mx-auto mt-5" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">Tambah Konsumen</h5>
<hr>
<form action="" method="post">
<p class="card-text">
<div class="input-group mb-3">
<span class="input-group-text" id="nama_lengkap"><i class="bi bi-person-fill"></i></span>
<input type="text" name="nama_lengkap" class="form-control" placeholder="Nama Lengkap" aria-label="nama_lengkap" aria-describedby="nama_lengkap">
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="username">@</span>
<input type="text" name="username" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="username">
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="kata_sandi"><i class="bi bi-person-fill-lock"></i></span>
<input type="password" name="kata_sandi" class="form-control" placeholder="Kata sandi" aria-label="Kata_sandi" aria-describedby="kata_sandi">
</div>
</p>
<div class="d-flex justify-content-between">
<a href="./user.php" class="btn btn-secondary btn-sm">Kembali</a>
<button type="submit" name="tambah" class="btn btn-warning btn-sm">Tambah</button>
</div>
</form>
</div>
</div>
</div>
<?php include('./template/foot.php') ?>