-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_product.php
More file actions
77 lines (65 loc) · 2.16 KB
/
Copy pathadd_product.php
File metadata and controls
77 lines (65 loc) · 2.16 KB
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
<?php
include 'db.php';
if(isset($_POST['save'])){
$name = $_POST['product_name'];
$cat = $_POST['category_id'];
$sup = $_POST['supplier_id'];
$cost = $_POST['cost_price'];
$sell = $_POST['selling_price'];
$qty = $_POST['quantity'];
$re = $_POST['reorder_level'];
mysqli_query($conn,
"INSERT INTO products
(product_name, category_id, supplier_id, cost_price, selling_price, quantity, reorder_level)
VALUES
('$name','$cat','$sup','$cost','$sell','$qty','$re')"
);
header("Location: products.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Add Product</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<style>
a{
font: bold;
color: black;
text-decoration-line: none;
}
</style>
<body>
<div class="container mt-5 col-md-6">
<h3>Add New Product</h3>
<form method="POST">
<input class="form-control mb-2" name="product_name" placeholder="Product Name" required>
<select class="form-control mb-2" name="category_id" required>
<option value="">Select Category</option>
<?php
$res = mysqli_query($conn,"SELECT * FROM categories");
while($c = mysqli_fetch_assoc($res)){
echo "<option value='{$c['category_id']}'>{$c['category_name']}</option>";
}
?>
</select>
<select class="form-control mb-2" name="supplier_id" required>
<option value="">Select Supplier</option>
<?php
$res = mysqli_query($conn,"SELECT * FROM suppliers");
while($s = mysqli_fetch_assoc($res)){
echo "<option value='{$s['supplier_id']}'>{$s['supplier_name']}</option>";
}
?>
</select>
<input class="form-control mb-2" name="cost_price" placeholder="Cost Price" required>
<input class="form-control mb-2" name="selling_price" placeholder="Selling Price" required>
<input class="form-control mb-2" name="quantity" placeholder="Initial Quantity" required>
<input class="form-control mb-2" name="reorder_level" placeholder="Reorder Level" required>
<button class="btn btn-primary w-100" name="save">Add Product</button>
</form>
<a href="dashboard.php">⬅ Back</a>
</div>
</body>
</html>