-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedit_product.php
158 lines (139 loc) · 5.13 KB
/
edit_product.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
<?php
ob_start();
include('header.php');
$get_id = $_GET['id'];
?>
<body>
<div id="wrapper">
<nav class="navbar navbar-default top-navbar" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">Personal Project</a>
</div>
<ul class="nav navbar-top-links navbar-right">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
Welcome : Administrator
</a>
<!-- /.dropdown-user -->
</li>
<!-- /.dropdown -->
</ul>
</nav>
<!--/. NAV TOP -->
<?php include ('nav_sidebar.php');?>
<!-- /. NAV SIDE -->
<div id="page-wrapper" >
<div id="page-inner">
<div class="row">
<div class="col-md-5 well">
<div class="hero-unit-table">
<div class="hero-unit-table">
<?php include ('connect.php');
$query = mysqli_query($aVar,"select * from tb_products where productID='$get_id'");
$row = mysqli_fetch_array($query);
?>
<form class="form-horizontal" method="post" enctype="multipart/form-data">
<div class="alert alert-info"><strong>Edit Book</strong> </div>
<hr>
<div class="control-group">
<label class="control-label" for="inputEmail">Name</label>
<div class="controls">
<input type="text" name="name" id="inputEmail" class = "form-control" value="<?php echo $row['name']; ?>">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Description</label>
<div class="controls">
<input type="text" name="description" class = "form-control" value="<?php echo $row['description']; ?>">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Category</label>
<div class="controls">
<select type="text" name="category" class = "form-control" >
<option><?php echo $row['category']; ?></option>
<option></option>
<option>HC12</option>
<option>HC13</option>
<option>HE19</option>
<option>HE20</option>
<option>HE21</option>
<option>HE22</option>
<option>HE23</option>
<option>GENERAL</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Publisher</label>
<div class="controls">
<input type="text" name="originated" class = "form-control" value="<?php echo $row['originated']; ?>">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Price</label>
<div class="controls">
<input type="text" name="price" class = "form-control" value="<?php echo $row['price']; ?>">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Quantity</label>
<div class="controls">
<input type="text" name="quantity" class = "form-control" value="<?php echo $row['quantity']; ?>">
</div>
</div>
<div class="control-group">
<label class="control-label" for="input01">Image:</label>
<div class="controls">
<input type="file" name="image">
</div>
</div>
<hr/>
<div class="control-group">
<div class="controls">
<button type="submit" name="update" class="btn btn-success"><i class="icon-save icon-large"></i> Update</button>
<span><a href = "product.php" class = "btn btn-danger"> Back</a></span>
</div>
</div>
</form>
<?php
if (isset($_POST['update'])) {
$name = $_POST['name'];
$description = $_POST['description'];
$category = $_POST['category'];
$originated = $_POST['originated'];
$price = $_POST['price'];
$quantity = $_POST['quantity'];
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes($_FILES['image']['name']);
$image_size = getimagesize($_FILES['image']['tmp_name']);
//
move_uploaded_file($_FILES["image"]["tmp_name"], "upload/" . $_FILES["image"]["name"]);
$location = "upload/" . $_FILES["image"]["name"];
mysqli_query($aVar,"update tb_products set name='$name',description='$description',category='$category',
originated='$originated',price='$price',quantity='$quantity',location='$location' where productID='$get_id'");
header('location: product.php');
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /. PAGE INNER -->
</div>
<!-- /. PAGE WRAPPER -->
</div>
<!-- /. WRAPPER -->
<!-- JS Scripts-->
<!-- jQuery Js -->
<?php include ('script.php');?>
</body>
</html>