forked from hawariMuflihMunte/pupuk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduct.add.php
More file actions
68 lines (61 loc) · 2.91 KB
/
product.add.php
File metadata and controls
68 lines (61 loc) · 2.91 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
68
<?php include('./template/head.php') ?>
<?php include('./php/connection.php') ?>
<?php
if (isset($_REQUEST['tambah'])) {
$gambar = mysqli_real_escape_string($connection, trim($_REQUEST['gambar']));
$nama_produk = mysqli_real_escape_string($connection, trim($_REQUEST['nama_produk']));
$jumlah = mysqli_real_escape_string($connection, trim($_REQUEST['jumlah']));
$sql = "INSERT INTO produk (
nama_produk,
gambar_produk,
jumlah_produk_kg
)
VALUES (
'$nama_produk',
'$gambar',
$jumlah
)
;";
$query = mysqli_query($connection, $sql);
if ($query) { // success
echo "<script>
window.alert('Berhasil menambah data produk')
window.location.href = './product.php'
</script>";
} else { // error
echo "<script>
window.alert('Gagal menambah data produk. 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 Produk</h5>
<hr>
<form action="" method="post">
<p class="card-text">
<div class="input-group mb-3">
<span class="input-group-text" id="gambar"><i class="bi bi-card-image"></i></span>
<input type="text" name="gambar" class="form-control" placeholder="Link gambar" aria-label="gambar" aria-describedby="gambar">
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="nama_produk">@</span>
<input type="text" name="nama_produk" class="form-control" placeholder="Nama produk" aria-label="nama_produk" aria-describedby="nama_produk">
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="jumlah"><i class="bi bi-diagram-2-fill"></i></span>
<input type="number" min="1" name="jumlah" class="form-control" placeholder="Jumlah" aria-label="jumlah" aria-describedby="jumlah">
<span class="input-group-text">kg</span>
</div>
</p>
<div class="d-flex justify-content-between">
<a href="./product.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') ?>