-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateProduct.php
90 lines (78 loc) · 3.34 KB
/
createProduct.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
<?php
// CONFIG DB
include("./app/config/config.php");
include("./app/core/createProduct.php");
if (!isset($_SESSION["user_id"])) {
header("location: login.php");
session_destroy();
}
if (isset($_POST["createProduct"])) {
$name = $_POST["name"];
$brand = $_POST["brand"];
$price = $_POST["price"];
$url = $_POST["url"];
$imageUrl = $_POST["urlImage"];
$category = $_POST["category"];
$stock = $_POST["stock"];
createProduct($name, $price, $category, $url, $brand, $imageUrl, $stock, $CONFIG);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<title>Product Creation</title>
</head>
<body>
<div class="container">
<br><br>
<h1>Product Creation</h1>
<br>
<form class="row g-3" action="" method="post" enctype="multipart/form-data">
<div class="col-md-6">
<label for="inputEmail4" class="form-label">Name</label>
<input type="text" class="form-control" name="name">
</div>
<div class="col-md-6">
<label for="inputEmail4" class="form-label">Brand</label>
<input type="text" class="form-control" name="brand">
</div>
<div class="col-md-6">
<label for="inputPassword4" class="form-label">Price</label>
<input type="text" class="form-control" name="price">
</div>
<div class="col-md-6">
<label for="inputCity" class="form-label">URL Image</label>
<input type="text" class="form-control" name="urlImage">
</div>
<div class="col-md-6">
<label for="inputCity" class="form-label">URL Page</label>
<input type="text" class="form-control" name="url">
</div>
<div class="col-md-6">
<label for="inputCity" class="form-label">Stock</label>
<input type="text" class="form-control" name="stock" value="0">
</div>
<div class="col-md-4">
<label for="inputState" class="form-label">Categories</label>
<select id="inputState" name="category" class="form-select">
<?php
$fetchCategories = "SELECT * FROM categories WHERE active = 1";
$result = mysqli_query($CONFIG, $fetchCategories);
while ($category = mysqli_fetch_array($result)) {
echo '<option>' . $category['name'] . '</option>';
}
?>
</select>
</div>
<div class="col-12">
<button type="submit" name="createProduct" class="btn btn-primary">Create Product</button>
</div>
</form>
</div>
</body>
</html>