forked from maiz-an/The-Gallery-Cafe-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_menu.php
More file actions
139 lines (118 loc) · 4.96 KB
/
Copy pathadd_menu.php
File metadata and controls
139 lines (118 loc) · 4.96 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
// Start the session
session_start();
// Check if the user is logged in as admin
if (!isset($_SESSION['username']) || $_SESSION['role'] !== 'admin') {
header("Location: login.html");
exit();
}
// Database connection details
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "product_website";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Handle form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
$description = $_POST['description'];
$price = $_POST['price'];
$stock = $_POST['stock'];
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
// Insert product into database
$sql = "INSERT INTO products (name, description, price, stock, image) VALUES ('$name', '$description', '$price', '$stock', '$image')";
if (mysqli_query($conn, $sql)) {
echo "<script>alert('Product added successfully!'); window.location.href = 'view_products.php';</script>";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
// Close the database connection
mysqli_close($conn);
?>
<!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>
<link rel="stylesheet" href="style/floating_contact_button.css">
<link rel="stylesheet" href="style/add_menu.css">
<link rel="stylesheet" href="style/h1.css">
<link rel="stylesheet" href="style/footer.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<style>
.cart-view {
display: block;
margin: 10px;
margin-left: 5px;
padding: 10px 20px;
background-color: #444;
color: white;
text-decoration: none;
border-radius: 12px;
text-align: center;
width: 105px;
}
.cart-view:hover {
background-color: #0a9660;
}
</style>
<header>
<h1>The Gallery Café - Admin</h1>
<div class="header-container">
<div class="title-nav">
<nav>
<ul>
<li><a href="admin_dashboard.php" class="nav-btn">Home</a></li>
<li><a href="admin_modify_user.php" class="nav-btn">Users</a></li>
<li><a href="view_products.php" class="nav-btn" style="color: #ffcc00;">Menu</a></li>
<li><a href="admin_manage_orders.php" class="nav-btn">Orders</a></li>
<li><a href="admin_manage_reservations.php" class="nav-btn">Reservation</a></li>
<li><a href="admin_manage_employee.php" class="nav-btn">Employees</a></li>
<li><a href="admin_view_payments.php" class="nav-btn">Payments</a></li>
<li><a href="admin_view_contacts.php" class="nav-btn">Feedbacks</a></li>
<li><a href="logout.php" class="nav-btn">Logout</a></li>
</ul>
</nav>
</div>
</div>
</header>
</head>
<body>
<div class="add-product-container">
<a href="view_products.php" class="cart-view">View Products</a>
<h2>Add New Product</h2>
<form action="add_menu.php" method="POST" enctype="multipart/form-data">
<label for="name">Product Name:</label>
<input type="text" id="name" name="name" required>
<label for="description">Description:</label>
<textarea id="description" name="description" required></textarea>
<label for="price">Price:</label>
<input type="number" id="price" name="price" step="0.01" min="1" max="500" required>
<label for="stock">Stock:</label>
<input type="number" id="stock" name="stock" min="1" max="300" required>
<label for="image">Product Image:</label>
<input type="file" id="image" name="image" accept="image/*" required>
<button type="submit">Add Product</button>
</form>
</div>
<footer>
<div class="footer-container">
<div class="social-icons">
<a href="https://facebook.com" target="_blank"><i class="fab fa-facebook-f"></i></a>
<a href="https://twitter.com" target="_blank"><i class="fab fa-twitter"></i></a>
<a href="https://instagram.com" target="_blank"><i class="fab fa-instagram"></i></a>
<a href="https://linkedin.com" target="_blank"><i class="fab fa-linkedin-in"></i></a>
</div>
<p>© 2024 The Gallery Café. All rights reserved.</p>
<p>123 Main Street, Colombo, Sri Lanka | Phone: +94 77 123 4567 | Email: info@gallerycafe.com</p>
</div>
</footer>
</body>
</html>