-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew_product.php
More file actions
91 lines (79 loc) · 2.84 KB
/
new_product.php
File metadata and controls
91 lines (79 loc) · 2.84 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
if (isset($_POST['add'])) {
$name = $_POST['name'];
$desc = $_POST['desc'];
$price = $_POST['price'];
$quantity = $_POST['quantity'];
$img = $_POST['img'];
$date_added = $_POST['date_added'];
try {
$sql = "INSERT INTO products (`name`, `desc`, `price`, `quantity`, `img`, `date_added`) VALUES (:name, :desc, :price, :quantity, :img, :date_added)";
$stmt = $pdo->prepare($sql);
$stmt->execute([
':name' => $name,
':desc' => $desc,
':price' => $price,
':quantity' => $quantity,
':img' => $img,
':date_added' => $date_added
]);
} catch (PDOException $e) {
die('PDO Error: ' . $e->getMessage());
}
}
?>
<!------------------------------------------------- LA PARTIE HTML/CSS DU NEW_PRODUIT ------------------------------------------------------->
<?= template_header('Cart') ?>
<style>
label {
width: 100px;
display: inline-block;
}
input[type="submit"] {
background: #4e5c70;
border: 0;
color: #ffffff;
width: 200px;
padding: 8px 0;
margin: 8px;
text-transform: uppercase;
font-size: 14px;
font-weight: bold;
border-radius: 5px;
}
</style>
<div class="add_product" style="margin:20px;">
<form method="post" action="index.php?page=new_product">
<center>
<table width="50%" border=1 cellpadding=5 cellspacing=0 style="margin-bottom:10px;">
<tr>
<td>
<center><strong>NEW PRODUCT</strong></center>
</td>
</tr>
</table>
<table width="50%" border="1" cellpadding=10 cellspacing=0>
<tr>
<td>
<center>
<label>name:</label>
<input type="text" name="name"></br><br>
<label>desc:</label>
<input type="text" name="desc"></br><br>
<label>price:</label>
<input type="text" name="price"></br><br>
<label>quantity:</label>
<input type="text" name="quantity"></br><br>
<label>image:</label>
<input type="text" name="img"></br><br>
<label>date:</label>
<input type="datetime-local" name="date_added"></br><br>
<input type="submit" name="add" value="add">
</center>
</td>
</tr>
</table>
</center>
</form>
</div>
<?= template_footer() ?>