diff --git a/admin.php b/admin.php
new file mode 100644
index 0000000..2543d8b
--- /dev/null
+++ b/admin.php
@@ -0,0 +1,56 @@
+prepare("SELECT * FROM admin_users WHERE username = :username");
+ $stmt->execute(['username' => $username]);
+ $user = $stmt->fetch();
+
+ if ($user) {
+ // Check if the password matches using bcrypt
+ if (password_verify($password, $user['password_hash'])) {
+ $_SESSION['admin_logged_in'] = true;
+ header('Location: admin_portal.php');
+ exit;
+ }
+ // Check if the password matches using SHA-256 (legacy support)
+ elseif (hash('sha256', $password) === $user['password_hash']) {
+ // Rehash the password with bcrypt for future logins
+ $new_hash = password_hash($password, PASSWORD_BCRYPT);
+ $update_stmt = $pdo->prepare("UPDATE admin_users SET password_hash = :new_hash WHERE id = :id");
+ $update_stmt->execute(['new_hash' => $new_hash, 'id' => $user['id']]);
+
+ $_SESSION['admin_logged_in'] = true;
+ header('Location: admin_portal.php');
+ exit;
+ }
+ }
+
+ // If neither bcrypt nor SHA-256 matched
+ $error = "Invalid username or password.";
+}
+?>
+
+
+
+
+
+
+
Admin Login
+
+
= htmlspecialchars($error) ?>
+
+
+
+
diff --git a/admin_portal.php b/admin_portal.php
new file mode 100644
index 0000000..4257163
--- /dev/null
+++ b/admin_portal.php
@@ -0,0 +1,85 @@
+prepare("
+ INSERT INTO restaurants (name, google_map_link, menu_link, cost_category, food_type, food_type_subcategory)
+ VALUES (:name, :google_map_link, :menu_link, :cost_category, :food_type, :food_type_subcategory)
+ ");
+ $stmt->execute([
+ 'name' => $name,
+ 'google_map_link' => $google_map_link,
+ 'menu_link' => $menu_link,
+ 'cost_category' => $cost_category,
+ 'food_type' => $food_type,
+ 'food_type_subcategory' => $food_type_subcategory,
+ ]);
+ $success = "Restaurant added successfully!";
+}
+
+?>
+
+
+
+
+
+
+
Admin Portal
+
+
+
+
+
+
= htmlspecialchars($success) ?>
+
+
+
Add New Restaurant
+
+
+
+
diff --git a/dynamic_login_link.php b/dynamic_login_link.php
new file mode 100644
index 0000000..0f8cab7
--- /dev/null
+++ b/dynamic_login_link.php
@@ -0,0 +1,21 @@
+
+
+
+ Home
+ Add Restaurants
+ Manage Restaurants
+
+';
+} else {
+ echo '
Login ';
+}
+?>
\ No newline at end of file
diff --git a/edit_restaurant.php b/edit_restaurant.php
new file mode 100644
index 0000000..003af44
--- /dev/null
+++ b/edit_restaurant.php
@@ -0,0 +1,88 @@
+prepare("SELECT * FROM restaurants WHERE id = :id");
+$stmt->execute(['id' => $id]);
+$restaurant = $stmt->fetch();
+
+if (!$restaurant) {
+ echo "Restaurant not found.";
+ exit;
+}
+
+if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ $name = $_POST['name'];
+ $google_map_link = $_POST['google_map_link'];
+ $menu_link = $_POST['menu_link'];
+ $cost_category = $_POST['cost_category'];
+ $food_type = $_POST['food_type'];
+ $food_type_subcategory = $_POST['food_type_subcategory'];
+
+ $stmt = $pdo->prepare("
+ UPDATE restaurants
+ SET name = :name, google_map_link = :google_map_link, menu_link = :menu_link,
+ cost_category = :cost_category, food_type = :food_type, food_type_subcategory = :food_type_subcategory
+ WHERE id = :id
+ ");
+ $stmt->execute([
+ 'name' => $name,
+ 'google_map_link' => $google_map_link,
+ 'menu_link' => $menu_link,
+ 'cost_category' => $cost_category,
+ 'food_type' => $food_type,
+ 'food_type_subcategory' => $food_type_subcategory,
+ 'id' => $id,
+ ]);
+
+ header('Location: manage.php');
+ exit;
+}
+?>
+
+
+
+
+
+
+
Restaurant Picker - Edit Restaurant
+
+
+
+
+
Edit Restaurant
+
+
+
+
diff --git a/header.php b/header.php
new file mode 100644
index 0000000..0d83108
--- /dev/null
+++ b/header.php
@@ -0,0 +1,26 @@
+
+
Restaurant Picker
+
+
+
+ Home
+ Add Restaurants
+ Manage Restaurants
+ Manage Users
+ Log Out
+
+';
+} else {
+ echo '
Admin
';
+}
+?>
+
\ No newline at end of file
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..6163c00
--- /dev/null
+++ b/index.php
@@ -0,0 +1,144 @@
+ $keyword) {
+ // Use LIKE to match the subcategory
+ $subquery[] = "food_type_subcategory LIKE :food_type_subcategory_{$index}";
+ $params["food_type_subcategory_{$index}"] = "%{$keyword}%";
+ }
+
+ // Join the subqueries with OR to match any of the keywords
+ $query .= " AND (" . implode(' OR ', $subquery) . ")";
+ }
+
+ // Random selection with a limit of 1 result
+ $query .= " ORDER BY RAND() LIMIT 1";
+
+ // Prepare and execute the query
+ $stmt = $pdo->prepare($query);
+ $stmt->execute($params);
+ $restaurant = $stmt->fetch();
+}
+?>
+
+
+
+
+
+
+
Restaurant Picker
+
+
+
+
+
+
+
+
+
Selected Restaurant:
+
= htmlspecialchars($restaurant['name']) ?>
+
View Menu
+
+
+
+
+
+
+
+
No results found based on your criteria.
+
+
+
+
+
diff --git a/logout.php b/logout.php
new file mode 100644
index 0000000..2b8f290
--- /dev/null
+++ b/logout.php
@@ -0,0 +1,6 @@
+
diff --git a/manage.php b/manage.php
new file mode 100644
index 0000000..30e84b1
--- /dev/null
+++ b/manage.php
@@ -0,0 +1,69 @@
+prepare("DELETE FROM restaurants WHERE id = :id");
+ $stmt->execute(['id' => $delete_id]);
+ header('Location: admin_portal.php');
+ exit;
+}
+
+// Fetch Restaurants for Display
+$restaurants = $pdo->query("SELECT * FROM restaurants")->fetchAll();
+?>
+
+
+
+
+
+
+
Admin Portal
+
+
+
+
+
Manage Restaurants
+
+
= htmlspecialchars($success) ?>
+
+
+
+ Name
+ Menu Link
+ Cost Category
+ Food Type
+ Subcategory
+ Actions
+
+
+
+ = htmlspecialchars($restaurant['name']) ?>
+
+
+ View Menu
+
+ N/A
+
+
+ = htmlspecialchars($restaurant['cost_category']) ?>
+ = htmlspecialchars($restaurant['food_type']) ?>
+ = htmlspecialchars($restaurant['food_type_subcategory']) ?>
+
+ Edit
+ |
+ Delete
+
+
+
+
+
+
+
diff --git a/subcategory_suggestions.php b/subcategory_suggestions.php
new file mode 100644
index 0000000..745f75c
--- /dev/null
+++ b/subcategory_suggestions.php
@@ -0,0 +1,26 @@
+prepare("
+ SELECT DISTINCT food_type_subcategory
+ FROM restaurants
+ WHERE food_type_subcategory LIKE :query
+ ");
+ $stmt->execute(['query' => "%$query%"]);
+
+ while ($row = $stmt->fetch()) {
+ $keywords = array_map('trim', explode(',', $row['food_type_subcategory']));
+ foreach ($keywords as $keyword) {
+ if (stripos($keyword, $query) !== false && !in_array($keyword, $suggestions)) {
+ $suggestions[] = $keyword;
+ }
+ }
+ }
+}
+
+header('Content-Type: application/json');
+echo json_encode($suggestions);
diff --git a/usradm.php b/usradm.php
new file mode 100644
index 0000000..65b9492
--- /dev/null
+++ b/usradm.php
@@ -0,0 +1,122 @@
+prepare("INSERT INTO admin_users (username, password_hash) VALUES (:username, :password_hash)");
+ $stmt->execute(['username' => $username, 'password_hash' => $password_hash]);
+ $message = "User added successfully!";
+ } catch (PDOException $e) {
+ $message = "Error: " . $e->getMessage();
+ }
+}
+
+// Handle deleting a user
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'delete_user') {
+ $user_id = $_POST['user_id'];
+
+ try {
+ $stmt = $pdo->prepare("DELETE FROM admin_users WHERE id = :id");
+ $stmt->execute(['id' => $user_id]);
+ $message = "User deleted successfully!";
+ } catch (PDOException $e) {
+ $message = "Error: " . $e->getMessage();
+ }
+}
+
+// Handle updating a user's password
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'update_password') {
+ $user_id = $_POST['user_id'];
+ $new_password = $_POST['new_password'];
+
+ // Hash the new password
+ $password_hash = password_hash($new_password, PASSWORD_BCRYPT);
+
+ try {
+ $stmt = $pdo->prepare("UPDATE admin_users SET password_hash = :password_hash WHERE id = :id");
+ $stmt->execute(['password_hash' => $password_hash, 'id' => $user_id]);
+ $message = "Password updated successfully!";
+ } catch (PDOException $e) {
+ $message = "Error: " . $e->getMessage();
+ }
+}
+
+// Fetch all users
+$users = $pdo->query("SELECT id, username FROM admin_users")->fetchAll(PDO::FETCH_ASSOC);
+?>
+
+
+
+
+
+
+
+
Admin - User Management
+
+
+
+
+
Admin - User Management
+
+
= htmlspecialchars($message) ?>
+
+
+
Add a New User
+
+
+
Existing Users
+
+
+ ID
+ Username
+ Actions
+ Password
+
+
+
+ = htmlspecialchars($user['id']) ?>
+ = htmlspecialchars($user['username']) ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+