-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.php
122 lines (113 loc) · 5.9 KB
/
update.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
<?php
include 'db-conn.php';
$id = $_GET['updateid'];
if(isset($_GET['updateid'])){
$id = $_GET['updateid'];
} else {
echo "<script>alert('Nomor Barang Belum Dipilih');document.location='index.php';</script>";
}
$sql = "SELECT * FROM inventaris WHERE id='$id'";
$result = mysqli_query($conn, $sql);
$data = mysqli_fetch_array($result);
$id = $data ['id'];
$brand = $data ['brand'];
$type = $data ['type'];
$amount = $data ['amount'];
$color = $data ['color'];
$owner = $data ['owner'];
$location = $data ['location'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="img/inventaris.png" type="image/x-icon">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<title>Update | INVENTARISKU.</title>
</head>
<body>
<div class="container" style="margin-top:65px;">
<div class="row justify-content-md-center" >
<div class="col-md-3 text-white" style="background-color: #375ca6; border-radius: 10px 0px 0px 10px; text-align: center;">
<img src="img/inventaris.png" style="width: 150px; height: 150px; margin-top: 45%;">
<h5 style="margin-top: 25%;"><strong>INVENTARISKU.</strong></h5>
<p style="font-size:11px; margin-top:3%;">let's set up the goods data collection system,<br>to get more focused and clear data</p>
<p style="font-size:10px; margin-top: 47%;"><strong>© 2022 Vocational School Graduate Academy</strong></p>
</div>
<div class="col-md-4" style="border-radius: 0px 10px 10px 0px; background-color:#e3f2fd;">
<div class="container-sm">
<div class="mt-3 mb-3">
<form action="" method="post">
<table class="table table-borderless" style="margin:auto; margin-top:55px; text-align: right; color: #375ca6;">
<tbody>
<tr>
<td></td>
<td><h6 style="text-align: left; margin-bottom: -3px;"><strong>INFORMATION OF GOODS</strong></h6></td>
</tr>
<tr>
<td><label for="id" class="form-label">ID</label></td>
<td><input type="text" class="form-control" id="id" name="id" value="<?php echo $data['id'];?>" readonly></td>
</tr>
<tr>
<td><label for="brand" class="form-label">Brand</label></td>
<td><input type="text" class="form-control" id="brand" name="brand" value="<?php echo $data['brand'];?>" required></td>
</tr>
<tr>
<td><label for="type" class="form-label">Type</label></td>
<td><input type="text" class="form-control" id="type" name="type" value="<?php echo $data['type']; ?>" required></td>
</tr>
<tr>
<td><label for="amount" class="form-label">Amount</label></td>
<td><input type="text" class="form-control" id="amount" name="amount" value="<?php echo $data['amount']; ?>" required></td>
</tr>
<tr>
<td><label for="color" class="form-label">Color</label></td>
<td> <input type="text" class="form-control" id="color" name="color" value="<?php echo $data['color']; ?>" required></td>
</tr>
<tr>
<td><label for="location" class="form-label">Location</label></td>
<td><input type="text" class="form-control" id="location" name="location" value="<?php echo $data['location']; ?>" required></td>
</tr>
<tr>
<td></td>
<td><h6 style="text-align: left; margin-top:5px; margin-bottom: -3px;"><strong>OWNERSHIP</strong></h6></td>
</tr>
<tr>
<td><label for="owner" class="form-label">Owner</label></td>
<td><input type="text" class="form-control" id="owner" name="owner" value="<?php echo $data['owner']; ?>" required></td>
</tr>
<tr>
<td></td>
<td style="text-align: left;">
<button type="submit" class="btn btn-success" name="update" id="update">Update</button>
<a href="index.php"><input type="button" class="btn text-white" style="background-color: #fe9677;" name="back" id="back" value="Back"></a>
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</div>
</body>
</html>
<?php
if (isset($_POST['update'])) {
$brand = $_POST['brand'];
$type = $_POST['type'];
$amount = $_POST['amount'];
$color = $_POST['color'];
$owner = $_POST['owner'];
$location = $_POST['location'];
$sql = "UPDATE inventaris SET brand='$brand', type='$type', amount='$amount', color='$color', owner='$owner', location='$location' WHERE id='$id'";
$result = mysqli_query($conn,$sql);
if($result){
echo "<script>alert('Has been update');document.location='index.php';</script>";
} else {
echo "<script>alert('Has been update');document.location='index.php';</script>";
}
}
?>