-
Notifications
You must be signed in to change notification settings - Fork 1
/
modal_add_product.php
113 lines (89 loc) · 3.15 KB
/
modal_add_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
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<div class="alert alert-info"><strong><center>Add Book </center></strong></div>
</div>
<div class="modal-body">
<form method="post" enctype="multipart/form-data">
<hr>
<div class="control-group">
<label class="control-label" for="inputEmail">Name:</label>
<input type="text" name="name" class = "form-control" placeholder="Name">
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Description:</label>
<div class="controls">
<input type="text" class = "form-control" name="description" placeholder="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" placeholder="Category" >
<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" placeholder="Publisher">
</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" splaceholder="Price" >
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Quantity:</label>
<div class="controls">
<input type="text" name="quantity" placeholder="Quantity" class = "form-control" >
</div>
</div>
<div class="control-group">
<label class="control-label" for="input01">Image:</label>
<div class="controls">
<input type="file" name="image">
</div>
</div>
<div class = "modal-footer">
<button name = "go" class="btn btn-primary">Save</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</form>
<?php include ('connect.php');
if (isset($_POST['go'])) {
$name = $_POST['name'];
$description = $_POST['description'];
$category = $_POST['category'];
$originated = $_POST['originated'];
$price = $_POST['price'];
$quantity = $_POST['quantity'];
//image
$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"];
mysql_query("insert into tb_products (name,description,category,originated,price,quantity,location)
values ('$name','$description','$category','$originated','$price','$quantity','$location')
");
header('location:product.php');
}
?>
</div>
</div>