-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.php
91 lines (59 loc) · 2.66 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
<!-- Form Update & Check Session -->
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Update</title>
</head>
<body>
<!-- If user has not logged in, Redirect to login.php -->
<?php
if (!isset($_SESSION["username"])){
header("Location: ./#.php");
}
?>
<!-- Show Error Message -->
<p style="color: red;">
<!-- [ERROR MESSAGE] -->
<?php
if (isset($_SESSION["error"])){
echo $_SESSION["error"];
}
?>
</p>
<?php
include "./database/dbProduct.php";
$id = $_GET["id"];
$query = "SELECT * FROM product WHERE id = ? ";
$statement = $connection->prepare($query);
$statement->bind_param("i",$id);
$statement->execute();
$result = $statement->get_result();
$statement->close();
if( $result->num_rows > 0){
$row = $result->fetch_assoc();
?>
<form class="form-horizontal" method="POST" action="./controller/doUpdate.php" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'];?>">
<input type="hidden" name="id" value=<?php echo $row["id"]; ?> >
<!-- id from selected product -->
<label class="control-label col-sm-2" for="nama">Nama:</label>
<!-- Show selected brand in value input type -->
<input type="text" class="form-control" id="nama" name="nama" placeholder="Enter Name" value=<?php echo $row["nama"]; ?>>
<label class="control-label col-sm-2" for="stock">Jumlah:</label>
<!-- Show selected type in value input type -->
<input type="text" class="form-control" id="jumlah" name="jumlah" placeholder="Enter Jumlah" value=<?php echo $row["stock"]; ?>>
<label class="control-label col-sm-2" for="harga">Price:</label>
<!-- Show selected price in value input type -->
<input type="text" class="form-control" id="harga" name="harga" placeholder="Enter Price" value=<?php echo $row["harga"]; ?>>
<label class="control-label col-sm-2" for="gambar">Image:</label>
<input type="file" id="gambar" name="gambar">
<button type="submit" class="btn btn-default">Submit</button></button>
</div>
</form>
<?php } ?>
</div>
</body>
</html>