-
Notifications
You must be signed in to change notification settings - Fork 0
/
ubah.php
114 lines (81 loc) · 2.42 KB
/
ubah.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
<?php
session_start();
if (! isset($_SESSION["login"])) {
header("location: login.php");
exit;
}
require 'function.php';
$id= $_GET["id"];
//setelah membuat id yang isinya didapat dari id diatas
//selanjutnya kita mengambil data/ atau query data bedasarkan id
$liq= query("SELECT * FROM tb_liq WHERE id = $id")[0];
//mengecek tombol submit sudah ditekan sprt pd materi sebelumnya
if (isset($_POST["submit"])) {
//cek data berhasil diubah atau tidak
if (ubah ($_POST)>0 ) {
//SCRIPT adalah syntax dari java script, disini digunakan untuk setelah data diubah langsung mendirect ke halaman index
//jika pada php bisa menggunakan header.location 'name.file' seperti pada materi sebelumnya.
echo "
<script>
alert('data berhasil diubah!');
document.location.href='index.php' ;
</script>" ;
}
else
{
echo " <script>
alert('data gagal diubah!');
document.location.href='index.php' ;
</script>
";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Ubah data liquid</title>
</head>
<body>
<h1>Ubah Data Liquid</h1>
<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?= $liq["id"]; ?>">
<input type="hidden" name="gambarlama" value="<?= $liq["gambar"]; ?>">
<ul>
<li>
<label for="product"> Product : </label>
<input type="text" name="product" id="product" required=""
value="<?= $liq["product"]; ?>">
</li>
<li>
<label for="nama"> Nama Liquid : </label>
<input type="text" name="nama" id="nama" required=""
value="<?= $liq["nama"]; ?>">
</li>
<li>
<label for="type"> Type Liquid : </label>
<input type="text" name="type" id="type"
value="<?= $liq["type"]; ?>">
</li>
<li>
<label for="flavor"> Flavor Liquid : </label>
<input type="text" name="flavor" id="flavor"
value="<?= $liq["flavor"]; ?>">
</li>
<li>
<label for="nicotine"> Nicotine : </label>
<input type="text" name="nicotine" id="nicotine"
value="<?= $liq["nicotine"]; ?>">
</li>
<li>
<label for="gambar"> Gambar : </label><br>
<img src="img/<?= $liq["gambar"] ?>" width="100" ><br>
<input type="file" name="gambar" id="gambar" >
</li>
<li>
<button type="submit" name="submit"> Ubah Data Liquid !</button>
</li>
</ul>
</form>
</body>
</html>