-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchange.php
159 lines (136 loc) · 5.68 KB
/
change.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
session_start();
// cek user login
if (!isset($_SESSION["loginadmin"])) {
header("Location: login.php");
exit;
}
// koneksi
require '../functions.php';
// ambil data di url
$id = $_GET["id"];
//query data product berdasarkan id
$prdct = query("SELECT * FROM product WHERE id = $id")[0];
// cek apakah tombol submit sudah di tekan atau belum
if (isset($_POST["submit"])) {
// cek apakah data berhasil ditambahkan atau tidak
if (ubah($_POST) > 0) {
echo "
<script>
alert('Data Changed Successfully!');
document.location.href = 'product.php';
</script>
";
} else {
echo "
<script>
alert('Data Failed To Change!');
document.location.href = 'product.php';
</script>
";
}
}
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<!-- My CSS -->
<link rel="stylesheet" href="../css/navbar.css">
<link rel="stylesheet" href="../css/index.css">
<!-- Font Goole -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Pacifico&family=Poppins:wght@300&display=swap"
rel="stylesheet">
<!-- Bootstrap Icon -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<title>Change Product</title>
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-dark bg-primary shadow-lg fixed-top">
<div class="container">
<a class="navbar-brand">Gudang Computer</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto fw-bold text-uppercase">
<li class="nav-item">
<a class="nav-link text-white" href="index.php">HOME</a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="orderlist.php">Order List</a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="product.php">Product</a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="logoutadmin.php"
onclick="return confirm('Are You Sure?')">Logout</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Akhir Navbar -->
<section class="container">
<!-- Header -->
<section class="jumbotron text-center mb-4" style="margin-top: 100px;">
<h1 class="display-5 text-uppercase fw-bold">Change Product</h1>
<hr class="text-primary underline">
</section>
<!-- Akhir Header -->
<!-- Form Tambah Data -->
<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?= $prdct["id"]; ?>">
<input type="hidden" name="gambarLama" value="<?= $prdct["gambar"]; ?>">
<div class="mb-4">
<input type="text" class="form-control" id="nama" name="nama" placeholder="Name"
value="<?= $prdct["nama"]; ?>">
</div>
<div class="mb-4">
<input type="url" class="form-control" id="spesifikasi" name="spesifikasi" placeholder="Specification"
value="<?= $prdct["spesifikasi"]; ?>">
</div>
<div class="mb-4">
<input type="number" class="form-control" id="stock" name="stock" placeholder="Stock"
value="<?= $prdct["stock"]; ?>">
</div>
<div class="mb-4">
<input type="text" class="form-control" id="price" name="price" placeholder="Price"
value="<?= $prdct["price"]; ?>">
</div>
<div class="mb-3">
<input type="file" class="form-control" id="gambar" name="gambar" placeholder="Image"
value="<?= $prdct["gambar"]; ?>">
</div>
<button type="submit" class="btn btn-primary mb-4" name="submit"><i class="bi bi-upload"></i></button>
</form>
<!-- Akhir Form Tambah Data -->
</section>
<!-- Footer -->
<footer id="footer" class="py-4 bg-primary position-relative">
<div class="container-md text-center text-white fs-6">
<p class="my-0">© Copyright <span class="fw-bold">gudangcomputer</span>. All Rights Reserved.</p>
<p class="my-0">
Created & Design
by
<span class="fw-bold">@Egiditya.</span>
</p>
</div>
</footer>
<!-- Akhir Footer -->
<!-- JS Bootstrap -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous">
</script>
</body>
</html>