[f9c482b] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | session_start();
|
---|
| 4 |
|
---|
| 5 | if(!isset($_SESSION['user_ID']) || !isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) {
|
---|
| 6 | header("Location: ./Log In.php");
|
---|
| 7 | }
|
---|
| 8 |
|
---|
| 9 | require 'connect.php';
|
---|
| 10 |
|
---|
| 11 | $id = $_GET['product_id'];
|
---|
| 12 |
|
---|
| 13 | $stmt = $conn->prepare("SELECT * FROM products WHERE product_id = ?");
|
---|
| 14 | $stmt->bind_param("i", $id);
|
---|
| 15 | $stmt->execute();
|
---|
| 16 | $result = $stmt->get_result();
|
---|
| 17 | $row = $result->fetch_assoc();
|
---|
| 18 |
|
---|
| 19 | $id = isset($row['product_id']) ? $row['product_id'] : '';
|
---|
| 20 | $name = isset($row['name']) ? $row['name'] : '';
|
---|
| 21 | $price = isset($row['price']) ? $row['price'] : '';
|
---|
| 22 | $discount = isset($row['discount']) ? $row['discount'] : '';
|
---|
| 23 | $instock = isset($row['instock']) ? $row['instock'] : '';
|
---|
| 24 | $category = isset($row['category']) ? $row['category'] : '';
|
---|
| 25 | $description = isset($row['description']) ? $row['description'] : '';
|
---|
| 26 |
|
---|
| 27 | $image1 = $row['image1'];
|
---|
| 28 | $image2 = $row['image2'];
|
---|
| 29 | $image3 = $row['image3'];
|
---|
| 30 | $image4 = $row['image4'];
|
---|
| 31 |
|
---|
| 32 | //OPIS
|
---|
| 33 | $brand = isset($row['brand']) ? $row['brand'] : '';
|
---|
| 34 | $series = isset($row['series']) ? $row['series'] : '';
|
---|
| 35 | $modelNumber = isset($row['model_number']) ? $row['model_number'] : '';
|
---|
| 36 | $weight = isset($row['weight']) ? $row['weight'] : '';
|
---|
| 37 | $dimensions = isset($row['dimensions']) ? $row['dimensions'] : '';
|
---|
| 38 | $color = isset($row['color']) ? $row['color'] : '';
|
---|
| 39 | $manufactuer = isset($row['manufactuer']) ? $row['manufactuer'] : '';
|
---|
| 40 | $origin = isset($row['origin']) ? $row['origin'] : '';
|
---|
| 41 | $firstDate = isset($row['firstDate']) ? $row['firstDate'] : '';
|
---|
| 42 | $energy = isset($row['energy']) ? $row['energy'] : '';
|
---|
| 43 | $volts = isset($row['volts']) ? $row['volts'] : '';
|
---|
| 44 | $memorySpeed = isset($row['memorySpeed']) ? $row['memorySpeed'] : '';
|
---|
| 45 | $usb3 = isset($row['usb3']) ? $row['usb3'] : '';
|
---|
| 46 | $usb2 = isset($row['usb2']) ? $row['usb2'] : '';
|
---|
| 47 | $processorBrand = isset($row['processorBrand']) ? $row['processorBrand'] : '';
|
---|
| 48 | $numProcess = isset($row['numProcess']) ? $row['numProcess'] : '';
|
---|
| 49 | $typeMem = isset($row['typeMem']) ? $row['typeMem'] : '';
|
---|
| 50 | $HardDD = isset($row['HardDD']) ? $row['HardDD'] : '';
|
---|
| 51 | $HardPlat = isset($row['HardPlat']) ? $row['HardPlat'] : '';
|
---|
| 52 | $HardFlash = isset($row['HardFlash']) ? $row['HardFlash'] : '';
|
---|
| 53 | $HardInterface = isset($row['HardInterface']) ? $row['HardInterface'] : '';
|
---|
| 54 | $gpuRAM = isset($row['gpuRAM']) ? $row['gpuRAM'] : '';
|
---|
| 55 | $motherboardRAM = isset($row['motherboardRAM']) ? $row['motherboardRAM'] : '';
|
---|
| 56 | $matherboardType = isset($row['matherboardTYPE']) ? $row['matherboardTYPE'] : '';
|
---|
| 57 | $screenSize = isset($row['screenSize']) ? $row['screenSize'] : '';
|
---|
| 58 | $screenRes = isset($row['screenRes']) ? $row['screenRes'] : '';
|
---|
| 59 | $screenMax = isset($row['screenMax']) ? $row['screenMax'] : '';
|
---|
| 60 |
|
---|
| 61 | ?>
|
---|
| 62 | <html>
|
---|
| 63 | <head>
|
---|
| 64 | <title>Edit Data</title>
|
---|
| 65 | <link rel="stylesheet" href="./CSS/AddProduct.css">
|
---|
| 66 | </head>
|
---|
| 67 | <style>
|
---|
| 68 | .file-input-container {
|
---|
| 69 | margin-bottom: 20px;
|
---|
| 70 | margin-right: 25px;
|
---|
| 71 | width: 100px;
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | .file-input-container label {
|
---|
| 75 | display: block;
|
---|
| 76 | width: auto;
|
---|
| 77 | font-size: 14px;
|
---|
| 78 | }
|
---|
| 79 | </style>
|
---|
| 80 | <body>
|
---|
| 81 | <h2 style="text-align: center">Edit Data</h2>
|
---|
| 82 | <p>
|
---|
| 83 | <a href="FetchData.php">Home</a>
|
---|
| 84 | </p>
|
---|
| 85 |
|
---|
| 86 | <form name="edit" method="post" action="FetchUpdater.php" enctype="multipart/form-data">
|
---|
| 87 | <div class="container">
|
---|
| 88 | <div class="productinfo">
|
---|
| 89 | <label>
|
---|
| 90 | PRODUCT ID:
|
---|
| 91 | </label>
|
---|
| 92 | <input type="number" name="product_id" value="<?php echo $id ?>">
|
---|
| 93 | <label>Name</label>
|
---|
| 94 | <input type="text" name="productName" value="<?php echo $name; ?>" required>
|
---|
| 95 | <label>Price</label>
|
---|
| 96 | <input type="number" name="productPrice" value="<?php echo $price; ?>" required>
|
---|
| 97 | <label>Discount</label>
|
---|
| 98 | <input type="number" name="productDiscount" min="0" max="70" value="<?php echo $discount; ?>" required>
|
---|
| 99 | <label>inStock</label>
|
---|
| 100 | <select name="inStock" value="<?php echo $instock; ?>">
|
---|
| 101 | <option value="false">No</option>
|
---|
| 102 | <option value="true">Yes</option>
|
---|
| 103 | </select>
|
---|
| 104 | <label>Category</label>
|
---|
| 105 | <select name="productCategory" value="<?php echo $category; ?>">
|
---|
| 106 | <option value="CPU">CPU</option>
|
---|
| 107 | <option value="GPU">GPU</option>
|
---|
| 108 | <option value="Motherboards">Motherboard</option>
|
---|
| 109 | <option value="PSU">Power Supply</option>
|
---|
| 110 | <option value="Monitor">Monitor</option>
|
---|
| 111 | <option value="Peripherals">Peripherals</option>
|
---|
| 112 | <option value="Cases">Cases</option>
|
---|
| 113 | <option value="Storage">Data</option>
|
---|
| 114 | </select>
|
---|
| 115 | <label>Description</label>
|
---|
| 116 | <textarea name="productDesc" required><?php echo $description; ?> </textarea>
|
---|
| 117 | <!-- IMAGES -->
|
---|
| 118 | <div class="imageCon">
|
---|
| 119 | <label>Images</label>
|
---|
| 120 | <div class="file-input-container">
|
---|
| 121 | <input type="file" name="images[]" id="filechooser">
|
---|
| 122 | <label style="font-size: 14px;"> <?php if(isset($image1)){echo $image1;} ?> </label>
|
---|
| 123 | </div>
|
---|
| 124 | <div class="file-input-container">
|
---|
| 125 | <input type="file" name="images[]" id="filechooser">
|
---|
| 126 | <label style="font-size: 14px;"> <?php if(isset($image2)){echo $image2;} ?> </label>
|
---|
| 127 | </div>
|
---|
| 128 | <div class="file-input-container">
|
---|
| 129 | <input type="file" name="images[]" id="filechooser">
|
---|
| 130 | <label style="font-size: 14px;"><?php if(isset($image3)){echo $image3;} ?> </label>
|
---|
| 131 | </div>
|
---|
| 132 | <div class="file-input-container">
|
---|
| 133 | <input type="file" name="images[]" id="filechooser">
|
---|
| 134 | <label style="font-size: 14px;"><?php if(isset($image4)){echo $image4;} ?> </label>
|
---|
| 135 | </div>
|
---|
| 136 | </div>
|
---|
| 137 | <!-- IMAGES -->
|
---|
| 138 | </div>
|
---|
| 139 |
|
---|
| 140 | <ul id="myUL">
|
---|
| 141 | <li><span class="opisList">Опис</span>
|
---|
| 142 | <ul class="nested">
|
---|
| 143 | <li>
|
---|
| 144 | <input type="checkbox" class="toggle-input" name="brand" checked>Бренд
|
---|
| 145 | <input type="text" class="text-field" name="brand-value" value="<?php echo $brand; ?>">
|
---|
| 146 | </li>
|
---|
| 147 | <li>
|
---|
| 148 | <input type="checkbox" class="toggle-input" name="series" checked>Серија
|
---|
| 149 | <input type="text" class="text-field" name="series-value" value="<?php echo $series; ?>">
|
---|
| 150 | </li>
|
---|
| 151 | <li>
|
---|
| 152 | <input type="checkbox" class="toggle-input" name="modelNumber" checked>Број на модел
|
---|
| 153 | <input type="text" class="text-field" name="modelnumber-value" value="<?php echo $modelNumber; ?>">
|
---|
| 154 | </li>
|
---|
| 155 | <li>
|
---|
| 156 | <input type="checkbox" class="toggle-input" name="weight" checked>Тежина
|
---|
| 157 | <input type="text" class="text-field" name="weight-value" value="<?php echo $weight; ?>">
|
---|
| 158 | </li>
|
---|
| 159 | <li>
|
---|
| 160 | <input type="checkbox" class="toggle-input" name="dimensions" checked>Димензии на производот
|
---|
| 161 | <input type="text" class="text-field" name="dimensions-value" value="<?php echo $dimensions; ?>">
|
---|
| 162 | </li>
|
---|
| 163 | <li>
|
---|
| 164 | <input type="checkbox" class="toggle-input" name="color" checked>Боја
|
---|
| 165 | <input type="text" class="text-field" name="color-value" value="<?php echo $color;?>" >
|
---|
| 166 | </li>
|
---|
| 167 | <li>
|
---|
| 168 | <input type="checkbox" class="toggle-input" name="manufactuer" checked>Производител
|
---|
| 169 | <input type="text" class="text-field" name="manufactuer-value" value="<?php echo $manufactuer; ?>">
|
---|
| 170 | </li>
|
---|
| 171 | <li>
|
---|
| 172 | <input type="checkbox" class="toggle-input" name="origin" checked>Земја на потекло
|
---|
| 173 | <input type="text" class="text-field" name="origin-value" value="<?php echo $origin; ?>">
|
---|
| 174 | </li>
|
---|
| 175 | <li>
|
---|
| 176 | <input type="checkbox" class="toggle-input" name="firstDate" checked>Прво достапен на датум
|
---|
| 177 | <input type="text" class="text-field" name="firstDate-value" value="<?php echo $firstDate; ?>">
|
---|
| 178 | </li>
|
---|
| 179 | <li><span class="opisList">More</span>
|
---|
| 180 | <ul class="nested">
|
---|
| 181 | <li>
|
---|
| 182 | <input type="checkbox" class="toggle-input" name="energy">Извор на енергија
|
---|
| 183 | <input type="text" class="text-field" name="energy-value" value="<?php echo $energy; ?>">
|
---|
| 184 | </li>
|
---|
| 185 | <li>
|
---|
| 186 | <input type="checkbox" class="toggle-input" name="volts">Волти
|
---|
| 187 | <input type="number" class="text-field" name="volts-value" value="<?php echo $volts; ?>">
|
---|
| 188 | </li>
|
---|
| 189 | <li>
|
---|
| 190 | <input type="checkbox" class="toggle-input" name="memorySpeed">Брзина на меморија
|
---|
| 191 | <input type="text" class="text-field" name="memorySpeed-value" value="<?php echo $memorySpeed; ?>">
|
---|
| 192 | </li>
|
---|
| 193 | <li>
|
---|
| 194 | <input type="checkbox" class="toggle-input" name="usb3">Број на USB 3.0 порти
|
---|
| 195 | <input type="number" class="text-field" name="usb3-value" value="<?php echo $usb3; ?>">
|
---|
| 196 | </li>
|
---|
| 197 | <li>
|
---|
| 198 | <input type="checkbox" class="toggle-input" name="usb2">Број на USB 2.0 порти
|
---|
| 199 | <input type="number" class="text-field" name="usb2-value" value="<?php echo $usb2; ?>">
|
---|
| 200 | </li>
|
---|
| 201 | <li><span class="opisList">Процесор</span>
|
---|
| 202 | <ul class="nested">
|
---|
| 203 | <li>
|
---|
| 204 | <input type="checkbox" class="toggle-input" name="processorBrand">Бренд на процесор
|
---|
| 205 | <input type="text" class="text-field" name="processorBrand-value" value="<?php echo $processorBrand; ?>">
|
---|
| 206 | </li>
|
---|
| 207 | <li>
|
---|
| 208 | <input type="checkbox" class="toggle-input" name="numProcess">Number of Processors
|
---|
| 209 | <input type="number" class="text-field" name="numProcess-value" value="<?php echo $numProcess; ?>">
|
---|
| 210 | </li>
|
---|
| 211 | <li>
|
---|
| 212 | <input type="checkbox" class="toggle-input" name="typeMem">Тип на меморија на компјутер
|
---|
| 213 | <input type="text" class="text-field" name="typeMem-value" value="<?php echo $typeMem; ?>">
|
---|
| 214 | </li>
|
---|
| 215 | </ul>
|
---|
| 216 | </li>
|
---|
| 217 | <li><span class="opisList">Disks</span>
|
---|
| 218 | <ul class="nested">
|
---|
| 219 | <li>
|
---|
| 220 | <input type="checkbox" class="toggle-input" name="HardDD">Hard Drive
|
---|
| 221 | <input type="text" class="text-field" name="HardDD-value" value="<?php echo $HardDD; ?>">
|
---|
| 222 | </li>
|
---|
| 223 | <li>
|
---|
| 224 | <input type="checkbox" class="toggle-input" name="HardPlat">Hardware Platform
|
---|
| 225 | <input type="text" class="text-field" name="HardPlat-value" value="<?php echo $HardPlat; ?>">
|
---|
| 226 | </li>
|
---|
| 227 | <li>
|
---|
| 228 | <input type="checkbox" class="toggle-input" name="HardFlash">Flash Memory Size
|
---|
| 229 | <input type="text" class="text-field" name="HardFlash-value" value="<?php echo $HardFlash; ?>">
|
---|
| 230 | </li>
|
---|
| 231 | <li>
|
---|
| 232 | <input type="checkbox" class="toggle-input" name="HardInterface">Hard Drive Interface
|
---|
| 233 | <input type="text" class="text-field" name="HardInterface-value" value="<?php echo $HardInterface; ?>">
|
---|
| 234 | </li>
|
---|
| 235 | </ul>
|
---|
| 236 | <li><span class="opisList">GPU</span>
|
---|
| 237 | <ul class="nested">
|
---|
| 238 | <li>
|
---|
| 239 | <input type="checkbox" class="toggle-input" name="gpuRAM">Graphics Card Ram Size
|
---|
| 240 | <input type="number" class="text-field" name="gpuRAM-value" value="<?php echo $gpuRAM; ?>">
|
---|
| 241 | </li>
|
---|
| 242 | </ul>
|
---|
| 243 | </li>
|
---|
| 244 | <li><span class="opisList">Motherboard</span>
|
---|
| 245 | <ul class="nested">
|
---|
| 246 | <li>
|
---|
| 247 | <input type="checkbox" class="toggle-input" name="motherboardRAM">RAM
|
---|
| 248 | <input type="number" class="text-field" name="motherboardRAM-value" value="<?php echo $motherboardRAM; ?>">
|
---|
| 249 | </li>
|
---|
| 250 | <li>
|
---|
| 251 | <input type="checkbox" class="toggle-input" name="matherboardType">Wireless Type
|
---|
| 252 | <input type="text" class="text-field" name="matherboardType-value" value="<?php echo $matherboardType; ?>">
|
---|
| 253 | </li>
|
---|
| 254 | </ul>
|
---|
| 255 | </li>
|
---|
| 256 | <li><span class="opisList">Monitor</span>
|
---|
| 257 | <ul class="nested">
|
---|
| 258 | <li>
|
---|
| 259 | <input type="checkbox" class="toggle-input" name="screenSize">Големина на екран
|
---|
| 260 | <input type="text" class="text-field" name="screenSize-value" value="<?php echo $screenSize; ?>">
|
---|
| 261 | </li>
|
---|
| 262 | <li>
|
---|
| 263 | <input type="checkbox" class="toggle-input" name="screenRes">Резолуција на екранот
|
---|
| 264 | <input type="text" class="text-field" name="screenRes-value" value="<?php echo $screenRes; ?>">
|
---|
| 265 | </li>
|
---|
| 266 | <li>
|
---|
| 267 | <input type="checkbox" class="toggle-input" name="screenMax">Максимална резолуција на екранот
|
---|
| 268 | <input type="text" class="text-field" name="screenMax-value" value="<?php echo $screenMax; ?>">
|
---|
| 269 | </li>
|
---|
| 270 | </ul>
|
---|
| 271 | </li>
|
---|
| 272 | </ul>
|
---|
| 273 | </li>
|
---|
| 274 | </ul>
|
---|
| 275 | </li>
|
---|
| 276 | </ul>
|
---|
| 277 | <button type="submit" class="btn-new-product" value="update" name="update">Confirm</button>
|
---|
| 278 | </div>
|
---|
| 279 | </form>
|
---|
| 280 |
|
---|
| 281 | <script>
|
---|
| 282 | var toggler = document.getElementsByClassName("opisList");
|
---|
| 283 | var i;
|
---|
| 284 |
|
---|
| 285 | for (i = 0; i < toggler.length; i++) {
|
---|
| 286 | toggler[i].addEventListener("click", function() {
|
---|
| 287 | this.parentElement.querySelector(".nested").classList.toggle("active");
|
---|
| 288 | this.classList.toggle("opisList-down");
|
---|
| 289 | });
|
---|
| 290 | }
|
---|
| 291 |
|
---|
| 292 |
|
---|
| 293 | </script>
|
---|
| 294 | </body>
|
---|
| 295 | </html> |
---|