forked from hawariMuflihMunte/pupuk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduct.edit.php
More file actions
104 lines (93 loc) · 3.92 KB
/
product.edit.php
File metadata and controls
104 lines (93 loc) · 3.92 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
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
<?php include('./template/head.php') ?>
<?php include('./php/connection.php') ?>
<?php
$id = $_GET['id'];
$sql = "SELECT
*
FROM
produk
WHERE
id = $id
;";
$query = mysqli_query($connection, $sql);
list($id, $nama_produk, $gambar, $jumlah) = mysqli_fetch_array($query);
?>
<?php
if (isset($_REQUEST['ubah'])) {
$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 = "UPDATE
produk
SET
nama_produk ='$nama_produk',
gambar_produk = '$gambar',
jumlah_produk_kg = $jumlah
WHERE
id = $id
;";
$query = mysqli_query($connection, $sql);
if ($query) { // success
echo "<script>
window.alert('Berhasil mengubah data produk')
window.location.href = './product.php'
</script>";
} else { // error
echo "<script>
window.alert('Gagal mengubah 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">Edit 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"
value="<?= $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"
value="<?= $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"
value="<?= $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="ubah" class="btn btn-warning btn-sm">Ubah</button>
</div>
</form>
</div>
</div>
</div>
<?php include('./template/foot.php') ?>