-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddProducts.php
217 lines (200 loc) · 5.53 KB
/
AddProducts.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<?php
session_start();
$conn = new mysqli('localhost','root','','shoe_store');
if(isset($_SESSION['email'])){
$jej = 1;
$email = $_SESSION['email'];
$verify = "SELECT access_token FROM registration WHERE email ='$email'";
$res = mysqli_query($conn,$verify);
}
else{
$jej = 0;
}
// error_reporting(0);
if (isset($_POST['upload'])) {
$filename = $_FILES["uploadfile"]["name"];
$tempname = $_FILES["uploadfile"]["tmp_name"];
$folder = "./images/" . $filename;
if(!isset($brand)){
$brand = $_POST['brand'] ?? '';
}
if(!isset($model)){
$model = $_POST['model'] ?? '';
}
if(!isset($gender)){
$gender = $_POST['gender'] ?? '';
}
if(!isset($size)){
$size = $_POST['size'] ?? '';
}
if(!isset($price)){
$price = $_POST['price'] ?? '';
}
if($conn->connect_error){
die('Connection Failed : '.$conn->connect_error);
}
else{
$stmt = $conn->prepare("insert into product(filename, brand, model, price, size, gender) values(?, ?, ?, ?, ?, ?)");
$stmt->bind_param("sssiis", $filename, $brand, $model, $price, $size, $gender);
$stmt->execute();
$stmt->close();
$conn->close();
header("Location: Kicks.php");
}
// $sql = "INSERT INTO product (filename, brand, model, price) VALUES ('$filename')";
// mysqli_query($conn, $sql);
if (move_uploaded_file($tempname, $folder)) {
echo "<h3> Image uploaded successfully!</h3>";
} else {
echo "<h3> Failed to upload image!</h3>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Add Product</title>
<script src="https://kit.fontawesome.com/b99e675b6e.js"></script>
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
</head>
<body>
<div class="wrapper">
<div class="main_content">
<div class="header">
<div class="leftIcon">
<a href="./Kicks.php"><i class="fas fa-arrow-left"> Back</i></a>
</div>
<span style="color:white">Add Product for Sale</span>
<div class="rightIcons" style="font-size: 0.5rem;">
<?php if($jej == 0){ ?>
<a href="Login.php"><i class="far fa-door-open fa-3x" style="color:white;"></i></a>
<?php }else {?>
<a href="Logout.php"><i class="far fa-door-closed fa-3x" style="color:white;"></i></a>
<?php } ?>
</div>
</div>
<div id="content">
<form method="POST" action="" enctype="multipart/form-data">
<label for="brand">Brand</label>
<input type="text" name="brand" size="40" class="pom" required="required"><br>
<label for="model">Model Name</label>
<input type="text" name="model" size="40" class="pom" required="required"><br>
<label for="model">Gender</label>
<input type="text" name="gender" size="40" class="pom" required="required"><br>
<label for="model">Size</label><br>
<input type="number" name="size" size="40" class="pom" required="required"><br>
<label for="price">Price</label><br>
<input type="number" step="0.01" name="price" size="40" class="pom" required="required"><br>
<label for="filename">Picture</label><br>
<div class="form-group">
<br>
<input class="form-control" type="file" name="uploadfile" value="" />
</div>
<div class="form-group">
<br>
<button class="btn" type="submit" name="upload">UPLOAD</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
<style>
@import url('https://fonts.googleapis.com/css?family=Josefin+Sans&display=swap');
*{
margin: 0;
padding: 0;
box-sizing: border-box;
list-style: none;
text-decoration: none;
}
* {box-sizing: border-box;}
.rightIcons {
position: fixed;
right: 0;
top: 0;
margin-top: 30px;
margin-right: 20px;
}
.leftIcon{
position: fixed;
left: 0;
top: 0;
margin-top: 30px;
margin-left: 20px;
color: white;
font-size: 20px;
}
body{
background-color: #e6e6e6;
}
.wrapper{
display: flex;
position: relative;
}
.wrapper .main_content{
width: 100%;
/* margin-left: 160px; */
}
.wrapper .main_content .header{
padding: 20px;
background: #262626;
color: #34b8d1;
text-align: center;
font-size: 40px;
font-family: 'Times New Roman', serif;
font-weight: bold;
border-bottom: 1px solid #e0e4e8;
margin-bottom: 20px;
}
.wrapper .main_content .header a{
color: #34b8d1;
}
.wrapper .main_content .header a:hover{
color: #fff;
}
#content{
width: 50%;
justify-content: center;
align-items: center;
margin: 20px auto;
border: 1px solid #cbcbcb;
font-size: 18px;
background: #262626;
border-radius: 15px;
color: #d5f0f6;
}
form{
width: 50%;
margin: 20px auto;
}
#display-image{
width: 100%;
justify-content: center;
padding: 5px;
margin: 15px;
}
img{
margin: 5px;
width: 350px;
height: 250px;
}
.btn{
padding: 10px 30px;
font-size: 15px;
border-radius: 15px;
cursor: pointer;
background: #34b8d1;
margin-left: 30%;
}
.pom{
margin: 10px;
padding: 8px;
border-radius: 10px;
}
.form-control{
margin-left: 10px;
padding: 3px;
font-size: 17px;
}