36874-vm/item_details.php
Flatlogic Bot dd86cddf44 1.2
2025-12-11 19:24:39 +00:00

60 lines
2.5 KiB
PHP

<?php include 'header.php'; ?>
<?php
require_once 'db/config.php';
$item = null;
if (isset($_GET['id'])) {
try {
$pdo = db();
$stmt = $pdo->prepare("SELECT * FROM items WHERE item_id = ?");
$stmt->execute([$_GET['id']]);
$item = $stmt->fetch();
} catch (PDOException $e) {
error_log("Database error fetching item: " . $e->getMessage());
// For production, you might redirect to an error page or show a generic error
header("Location: listings.php");
exit();
}
}
if (!$item) {
header("Location: listings.php");
exit();
}
?>
<?php
if (isset($_GET['message']) && isset($_GET['type'])) {
$message = htmlspecialchars($_GET['message']);
$type = htmlspecialchars($_GET['type']);
echo '<div class="alert alert-' . $type . ' alert-dismissible fade show" role="alert">';
echo $message;
echo '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
echo '</div>';
}
?>
<div class="container section">
<div class="row">
<div class="col-md-8 offset-md-2">
<div class="card mb-4 shadow-sm">
<img src="https://images.pexels.com/photos/276583/pexels-photo-276583.jpeg?auto=compress&cs=tinysrgb&w=800" class="card-img-top" alt="<?php echo htmlspecialchars($item['name']); ?>" style="height: 400px; object-fit: cover;">
<div class="card-body">
<h1 class="card-title display-4 mb-3"><?php echo htmlspecialchars($item['name']); ?></h1>
<h5 class="card-subtitle mb-2 text-muted"><i data-feather="map-pin"></i> <?php echo htmlspecialchars($item['location']); ?></h5>
<p class="card-text lead"><?php echo htmlspecialchars($item['description']); ?></p>
<hr>
<div class="d-flex justify-content-between align-items-center mt-3">
<h3 class="price-text">$<?php echo htmlspecialchars(number_format($item['price_per_day'], 2)); ?> / day</h3>
<form action="rent_item.php" method="POST">
<input type="hidden" name="item_id" value="<?php echo htmlspecialchars($item['item_id']); ?>">
<button type="submit" class="btn btn-primary btn-lg">Rent Now</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include 'footer.php'; ?>