-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost.php
More file actions
77 lines (57 loc) · 2.25 KB
/
Copy pathpost.php
File metadata and controls
77 lines (57 loc) · 2.25 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 "Connection.php";
if (isset($_POST['submit'])) {
$product_id = $_POST['product_id'];
$name = $_POST['name'];
$price = $_POST['price'];
$description = $_POST['description'];
$sql = "INSERT INTO products (product_id, name, price, description)
VALUES ('$product_id', '$name', '$price', '$description')";
if (mysqli_query($conn, $sql)) {
echo "<p style='color:green; text-align:center;'>Inserted Successfully!</p>";
} else {
echo "<p style='color:red; text-align:center;'>Error: " . mysqli_error($conn) . "</p>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Product</title>
</head>
<body style="margin:0; font-family: Arial, sans-serif; background: #f4f4f4;">
<div style="display:flex; justify-content:center; align-items:center; height:100vh;">
<form method="POST" style="
background: white;
padding: 30px;
width: 400px;
border-radius: 10px;
box-shadow: 0px 0px 15px rgba(0,0,0,0.2);
">
<h2 style="text-align:center; margin-bottom:20px;">Add Product</h2>
<label style="font-weight:bold;">Product ID</label>
<input type="number" name="product_id" required style="width:100%; padding:10px; margin:5px 0 15px;">
<label style="font-weight:bold;">Name</label>
<input type="text" name="name" required style="width:100%; padding:10px; margin:5px 0 15px;">
<label style="font-weight:bold;">Price</label>
<input type="text" name="price" required style="width:100%; padding:10px; margin:5px 0 15px;">
<label style="font-weight:bold;">Description</label>
<textarea name="description" required style="width:100%; padding:10px; margin:5px 0 15px; height:80px;"></textarea>
<!-- ✅ Submit button MUST have name="submit" for isset -->
<button type="submit" name="submit" style="
width: 100%;
padding: 12px;
background: green;
color: white;
border: none;
font-size: 16px;
cursor: pointer;
">
Insert
</button>
</form>
</div>
</body>
</html>