diff --git a/dashboard.php b/dashboard.php
index cef3829..dced25f 100644
--- a/dashboard.php
+++ b/dashboard.php
@@ -1,15 +1,34 @@
prepare("SELECT * FROM items WHERE renter_id = ? AND status = 'rented'");
+ $stmt->execute([$user_id]);
+ $items = $stmt->fetchAll();
+} elseif ($user_role === 'vendor') {
+ // Fetch items listed by the vendor
+ $stmt = $pdo->prepare("SELECT * FROM items WHERE owner_id = ?");
+ $stmt->execute([$user_id]);
+ $items = $stmt->fetchAll();
+}
+
?>
@@ -24,7 +43,43 @@ $user_role = $_SESSION['user_role'];
Welcome to your RentEase dashboard.
Your role is:
- Add New Item
+ Add New Item
+
+
+
+
+
+ Your Rented Items
+
+ Your Listed Items
+
+
+
+ No items found.
+
+
+
+
+
+
![<?php echo htmlspecialchars($item['name']); ?>](<?php echo htmlspecialchars($item['image_url'] ?? 'https://via.placeholder.com/150'); ?>)
+
+
+
+
Price: $ per day
+
Location:
+
+
+
+
+
+
Click here to log out.
diff --git a/item_details.php b/item_details.php
index c25dfb1..53f1ef8 100644
--- a/item_details.php
+++ b/item_details.php
@@ -24,6 +24,16 @@ if (!$item) {
}
?>
+';
+ echo $message;
+ echo '';
+ echo '';
+}
+?>
@@ -36,7 +46,10 @@ if (!$item) {
$ / day
-
+
diff --git a/rent_item.php b/rent_item.php
new file mode 100644
index 0000000..88f3a40
--- /dev/null
+++ b/rent_item.php
@@ -0,0 +1,56 @@
+prepare("SELECT status FROM items WHERE item_id = ?");
+ $stmt->execute([$item_id]);
+ $item = $stmt->fetch();
+
+ if ($item && $item['status'] === 'available') {
+ // Update item status to rented
+ $stmt = $pdo->prepare("UPDATE items SET status = 'rented', renter_id = ?, rented_date = NOW() WHERE item_id = ?");
+ $stmt->execute([$user_id, $item_id]);
+ $message = 'Item rented successfully!';
+ $message_type = 'success';
+ } else {
+ $message = 'Item is not available for rent or does not exist.';
+ $message_type = 'danger';
+ }
+ } catch (PDOException $e) {
+ error_log("Database error during rental: " . $e->getMessage());
+ $message = 'An error occurred during rental. Please try again.';
+ $message_type = 'danger';
+ }
+ } else {
+ $message = 'Invalid item ID.';
+ $message_type = 'danger';
+ }
+} else {
+ header('Location: listings.php'); // Redirect if not a POST request
+ exit();
+}
+
+// Redirect back to item details with message
+// You might want to pass these messages via session or URL parameters
+header('Location: item_details.php?id=' . $item_id . '&message=' . urlencode($message) . '&type=' . $message_type);
+exit();
+
+?>
\ No newline at end of file