1.1
This commit is contained in:
parent
448d685cc0
commit
1d182fef38
109
add_item.php
Normal file
109
add_item.php
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
// Ensure user is logged in and is a vendor
|
||||||
|
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'vendor') {
|
||||||
|
header("Location: login.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$vendor_id = $_SESSION['user_id'];
|
||||||
|
$name = $description = $price_per_day = $location = "";
|
||||||
|
$errors = [];
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$name = trim($_POST['name']);
|
||||||
|
$description = trim($_POST['description']);
|
||||||
|
$price_per_day = trim($_POST['price_per_day']);
|
||||||
|
$location = trim($_POST['location']);
|
||||||
|
|
||||||
|
if (empty($name)) {
|
||||||
|
$errors[] = "Item name is required.";
|
||||||
|
}
|
||||||
|
if (empty($price_per_day) || !is_numeric($price_per_day)) {
|
||||||
|
$errors[] = "A valid price is required.";
|
||||||
|
}
|
||||||
|
if (empty($location)) {
|
||||||
|
$errors[] = "Location is required.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($errors)) {
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$sql = "INSERT INTO items (vendor_id, name, description, price_per_day, location) VALUES (:vendor_id, :name, :description, :price_per_day, :location)";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute([
|
||||||
|
':vendor_id' => $vendor_id,
|
||||||
|
':name' => $name,
|
||||||
|
':description' => $description,
|
||||||
|
':price_per_day' => $price_per_day,
|
||||||
|
':location' => $location
|
||||||
|
]);
|
||||||
|
header("Location: dashboard.php?item_added=true");
|
||||||
|
exit();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$errors[] = "Database error: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Add New Item - RentEase</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<?php include 'header.php'; ?>
|
||||||
|
|
||||||
|
<div class="container mt-5">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h2>Add a New Rental Item</h2>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if (!empty($errors)): ?>
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<?php foreach ($errors as $error): ?>
|
||||||
|
<p><?php echo $error; ?></p>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<form action="add_item.php" method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="name" class="form-label">Item Name</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($name); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="description" class="form-label">Description</label>
|
||||||
|
<textarea class="form-control" id="description" name="description" rows="3"><?php echo htmlspecialchars($description); ?></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="price_per_day" class="form-label">Price per Day ($)</label>
|
||||||
|
<input type="number" class="form-control" id="price_per_day" name="price_per_day" step="0.01" value="<?php echo htmlspecialchars($price_per_day); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="location" class="form-label">Location (e.g., City, State)</label>
|
||||||
|
<input type="text" class="form-control" id="location" name="location" value="<?php echo htmlspecialchars($location); ?>" required>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Add Item</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php include 'footer.php'; ?>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
105
assets/css/custom.css
Normal file
105
assets/css/custom.css
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/* Google Fonts */
|
||||||
|
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&family=Lato:wght@400;700&display=swap');
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--primary-color: #1E90FF;
|
||||||
|
--secondary-color: #007BFF;
|
||||||
|
--background-color: #F8F9FA;
|
||||||
|
--surface-color: #FFFFFF;
|
||||||
|
--text-color: #212529;
|
||||||
|
--border-radius: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: 'Lato', sans-serif;
|
||||||
|
background-color: var(--background-color);
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
|
||||||
|
font-family: 'Poppins', sans-serif;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background-color: var(--primary-color);
|
||||||
|
border-color: var(--primary-color);
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
font-weight: 500;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover {
|
||||||
|
background-color: var(--secondary-color);
|
||||||
|
border-color: var(--secondary-color);
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-brand {
|
||||||
|
font-family: 'Poppins', sans-serif;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--primary-color) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero {
|
||||||
|
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
|
||||||
|
color: white;
|
||||||
|
padding: 8rem 0 6rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero h1 {
|
||||||
|
font-size: 3.5rem;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-bar {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 2rem auto 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input {
|
||||||
|
height: 3.5rem;
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-button {
|
||||||
|
height: 3.5rem;
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
.section {
|
||||||
|
padding: 4rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 3rem;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.how-it-works-icon {
|
||||||
|
font-size: 3rem;
|
||||||
|
color: var(--primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
border: none;
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card:hover {
|
||||||
|
transform: translateY(-5px);
|
||||||
|
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
background-color: var(--surface-color);
|
||||||
|
padding: 2rem 0;
|
||||||
|
border-top: 1px solid #e9ecef;
|
||||||
|
}
|
||||||
13
assets/js/main.js
Normal file
13
assets/js/main.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
const searchForm = document.getElementById('locationSearchForm');
|
||||||
|
if (searchForm) {
|
||||||
|
searchForm.addEventListener('submit', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
const locationInput = document.getElementById('locationInput');
|
||||||
|
const location = locationInput.value.trim();
|
||||||
|
if (location) {
|
||||||
|
window.location.href = `listings.php?location=${encodeURIComponent(location)}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
36
dashboard.php
Normal file
36
dashboard.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
// If user is not logged in, redirect to login page
|
||||||
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
header("Location: login.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user_name = $_SESSION['user_name'];
|
||||||
|
$user_role = $_SESSION['user_role'];
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php include 'header.php'; ?>
|
||||||
|
|
||||||
|
<div class="container mt-5">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h4>Welcome, <?php echo htmlspecialchars($user_name); ?>!</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p>Welcome to your RentEase dashboard.</p>
|
||||||
|
<p>Your role is: <strong><?php echo htmlspecialchars($user_role); ?></strong></p>
|
||||||
|
<?php if ($user_role === 'vendor'): ?>
|
||||||
|
<a href="add_item.php" class="btn btn-primary">Add New Item</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
<p><a href='logout.php'>Click here to log out.</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php include 'footer.php'; ?>
|
||||||
16
footer.php
Normal file
16
footer.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!-- Footer -->
|
||||||
|
<footer class="mt-auto">
|
||||||
|
<div class="container text-center py-4">
|
||||||
|
<p>© <?php echo date("Y"); ?> RentEase. All Rights Reserved.</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<!-- Scripts -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||||
|
<script>
|
||||||
|
feather.replace()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
61
header.php
Normal file
61
header.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?php if (session_status() === PHP_SESSION_NONE) { session_start(); } ?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
||||||
|
<title>RentEase - Your Neighborhood Rental Marketplace</title>
|
||||||
|
<meta name="description" content="<?php echo htmlspecialchars($_SERVER['PROJECT_DESCRIPTION'] ?? 'Rent anything, anytime, anywhere in your neighborhood.'); ?>">
|
||||||
|
|
||||||
|
<!-- Meta tags for social sharing -->
|
||||||
|
<meta property="og:title" content="RentEase - Your Neighborhood Rental Marketplace">
|
||||||
|
<meta property="og:description" content="<?php echo htmlspecialchars($_SERVER['PROJECT_DESCRIPTION'] ?? 'Rent anything, anytime, anywhere in your neighborhood.'); ?>">
|
||||||
|
<meta property="og:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
|
||||||
|
<meta property="og:url" content="/">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
|
||||||
|
<!-- Stylesheets -->
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
|
||||||
|
<!-- Icons -->
|
||||||
|
<script src="https://unpkg.com/feather-icons"></script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body style="padding-top: 70px;">
|
||||||
|
|
||||||
|
<!-- Header -->
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm fixed-top">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="index.php">RentEase</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav ms-auto align-items-center">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="listings.php">Browse</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">For Vendors</a>
|
||||||
|
</li>
|
||||||
|
<?php if (isset($_SESSION['user_id'])): ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="dashboard.php">Dashboard</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="btn btn-outline-primary ms-lg-2" href="logout.php">Logout</a>
|
||||||
|
</li>
|
||||||
|
<?php else: ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="login.php">Login</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="btn btn-outline-primary ms-lg-2" href="register.php">Sign Up</a>
|
||||||
|
</li>
|
||||||
|
<?php endif; ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
262
index.php
262
index.php
@ -1,150 +1,114 @@
|
|||||||
<?php
|
<?php include 'header.php'; ?>
|
||||||
declare(strict_types=1);
|
|
||||||
@ini_set('display_errors', '1');
|
|
||||||
@error_reporting(E_ALL);
|
|
||||||
@date_default_timezone_set('UTC');
|
|
||||||
|
|
||||||
$phpVersion = PHP_VERSION;
|
<!-- Hero Section -->
|
||||||
$now = date('Y-m-d H:i:s');
|
<header class="hero">
|
||||||
?>
|
<div class="container">
|
||||||
<!doctype html>
|
<h1 class="display-3">Your Neighborhood Rental Marketplace</h1>
|
||||||
<html lang="en">
|
<p class="lead">Rent anything, from anyone, right around the corner.</p>
|
||||||
<head>
|
<form class="search-bar" id="locationSearchForm">
|
||||||
<meta charset="utf-8" />
|
<div class="input-group">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<input type="text" class="form-control form-control-lg search-input" id="locationInput" placeholder="Enter your city, neighborhood, or address..." required>
|
||||||
<title>New Style</title>
|
<button class="btn btn-light btn-lg search-button" type="submit">
|
||||||
<?php
|
<i data-feather="search"></i> Search
|
||||||
// Read project preview data from environment
|
</button>
|
||||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
</div>
|
||||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
</form>
|
||||||
?>
|
</div>
|
||||||
<?php if ($projectDescription): ?>
|
</header>
|
||||||
<!-- Meta description -->
|
|
||||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
<!-- How It Works Section -->
|
||||||
<!-- Open Graph meta tags -->
|
<section class="section">
|
||||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
<div class="container">
|
||||||
<!-- Twitter meta tags -->
|
<h2 class="section-title">How It Works</h2>
|
||||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
<div class="row text-center">
|
||||||
<?php endif; ?>
|
<div class="col-md-4">
|
||||||
<?php if ($projectImageUrl): ?>
|
<div class="p-4">
|
||||||
<!-- Open Graph image -->
|
<i data-feather="map-pin" class="how-it-works-icon mb-3"></i>
|
||||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
<h3>1. Find Nearby</h3>
|
||||||
<!-- Twitter image -->
|
<p class="text-muted">Enter your location to discover thousands of items available for rent in your area.</p>
|
||||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
</div>
|
||||||
<?php endif; ?>
|
</div>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<div class="col-md-4">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<div class="p-4">
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
<i data-feather="calendar" class="how-it-works-icon mb-3"></i>
|
||||||
<style>
|
<h3>2. Book & Rent</h3>
|
||||||
:root {
|
<p class="text-muted">Select your item, choose your dates, and book instantly with secure payments.</p>
|
||||||
--bg-color-start: #6a11cb;
|
</div>
|
||||||
--bg-color-end: #2575fc;
|
</div>
|
||||||
--text-color: #ffffff;
|
<div class="col-md-4">
|
||||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
<div class="p-4">
|
||||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
<i data-feather="smile" class="how-it-works-icon mb-3"></i>
|
||||||
}
|
<h3>3. Enjoy & Return</h3>
|
||||||
body {
|
<p class="text-muted">Use your rental for as long as you need. Returning it is just as easy.</p>
|
||||||
margin: 0;
|
</div>
|
||||||
font-family: 'Inter', sans-serif;
|
</div>
|
||||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
</div>
|
||||||
color: var(--text-color);
|
</div>
|
||||||
display: flex;
|
</section>
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
<!-- Featured Items Section -->
|
||||||
min-height: 100vh;
|
<section class="section bg-light">
|
||||||
text-align: center;
|
<div class="container">
|
||||||
overflow: hidden;
|
<h2 class="section-title">Featured Items</h2>
|
||||||
position: relative;
|
<div class="row">
|
||||||
}
|
<!-- Placeholder Item 1 -->
|
||||||
body::before {
|
<div class="col-md-6 col-lg-3 mb-4">
|
||||||
content: '';
|
<div class="card h-100">
|
||||||
position: absolute;
|
<img src="https://images.pexels.com/photos/276583/pexels-photo-276583.jpeg?auto=compress&cs=tinysrgb&w=600" class="card-img-top" alt="Modern Chair" style="height: 200px; object-fit: cover;">
|
||||||
top: 0;
|
<div class="card-body d-flex flex-column">
|
||||||
left: 0;
|
<h5 class="card-title">Modern Chair</h5>
|
||||||
width: 100%;
|
<p class="card-text text-muted">Furniture</p>
|
||||||
height: 100%;
|
<div class="mt-auto d-flex justify-content-between align-items-center">
|
||||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
<strong>$10 / day</strong>
|
||||||
animation: bg-pan 20s linear infinite;
|
<a href="#" class="btn btn-primary btn-sm">Rent</a>
|
||||||
z-index: -1;
|
</div>
|
||||||
}
|
</div>
|
||||||
@keyframes bg-pan {
|
</div>
|
||||||
0% { background-position: 0% 0%; }
|
</div>
|
||||||
100% { background-position: 100% 100%; }
|
<!-- Placeholder Item 2 -->
|
||||||
}
|
<div class="col-md-6 col-lg-3 mb-4">
|
||||||
main {
|
<div class="card h-100">
|
||||||
padding: 2rem;
|
<img src="https://images.pexels.com/photos/356056/pexels-photo-356056.jpeg?auto=compress&cs=tinysrgb&w=600" class="card-img-top" alt="Laptop" style="height: 200px; object-fit: cover;">
|
||||||
}
|
<div class="card-body d-flex flex-column">
|
||||||
.card {
|
<h5 class="card-title">MacBook Pro</h5>
|
||||||
background: var(--card-bg-color);
|
<p class="card-text text-muted">Electronics</p>
|
||||||
border: 1px solid var(--card-border-color);
|
<div class="mt-auto d-flex justify-content-between align-items-center">
|
||||||
border-radius: 16px;
|
<strong>$25 / day</strong>
|
||||||
padding: 2rem;
|
<a href="#" class="btn btn-primary btn-sm">Rent</a>
|
||||||
backdrop-filter: blur(20px);
|
</div>
|
||||||
-webkit-backdrop-filter: blur(20px);
|
</div>
|
||||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
</div>
|
||||||
}
|
</div>
|
||||||
.loader {
|
<!-- Placeholder Item 3 -->
|
||||||
margin: 1.25rem auto 1.25rem;
|
<div class="col-md-6 col-lg-3 mb-4">
|
||||||
width: 48px;
|
<div class="card h-100">
|
||||||
height: 48px;
|
<img src="https://images.pexels.com/photos/3932930/pexels-photo-3932930.jpeg?auto=compress&cs=tinysrgb&w=600" class="card-img-top" alt="Camping Tent" style="height: 200px; object-fit: cover;">
|
||||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
<div class="card-body d-flex flex-column">
|
||||||
border-top-color: #fff;
|
<h5 class="card-title">Camping Tent</h5>
|
||||||
border-radius: 50%;
|
<p class="card-text text-muted">Outdoors</p>
|
||||||
animation: spin 1s linear infinite;
|
<div class="mt-auto d-flex justify-content-between align-items-center">
|
||||||
}
|
<strong>$15 / day</strong>
|
||||||
@keyframes spin {
|
<a href="#" class="btn btn-primary btn-sm">Rent</a>
|
||||||
from { transform: rotate(0deg); }
|
</div>
|
||||||
to { transform: rotate(360deg); }
|
</div>
|
||||||
}
|
</div>
|
||||||
.hint {
|
</div>
|
||||||
opacity: 0.9;
|
<!-- Placeholder Item 4 -->
|
||||||
}
|
<div class="col-md-6 col-lg-3 mb-4">
|
||||||
.sr-only {
|
<div class="card h-100">
|
||||||
position: absolute;
|
<img src="https://images.pexels.com/photos/164595/pexels-photo-164595.jpeg?auto=compress&cs=tinysrgb&w=600" class="card-img-top" alt="King Size Bed" style="height: 200px; object-fit: cover;">
|
||||||
width: 1px; height: 1px;
|
<div class="card-body d-flex flex-column">
|
||||||
padding: 0; margin: -1px;
|
<h5 class="card-title">King Size Bed</h5>
|
||||||
overflow: hidden;
|
<p class="card-text text-muted">Furniture</p>
|
||||||
clip: rect(0, 0, 0, 0);
|
<div class="mt-auto d-flex justify-content-between align-items-center">
|
||||||
white-space: nowrap; border: 0;
|
<strong>$30 / day</strong>
|
||||||
}
|
<a href="#" class="btn btn-primary btn-sm">Rent</a>
|
||||||
h1 {
|
</div>
|
||||||
font-size: 3rem;
|
</div>
|
||||||
font-weight: 700;
|
</div>
|
||||||
margin: 0 0 1rem;
|
</div>
|
||||||
letter-spacing: -1px;
|
</div>
|
||||||
}
|
</div>
|
||||||
p {
|
</section>
|
||||||
margin: 0.5rem 0;
|
|
||||||
font-size: 1.1rem;
|
<?php include 'footer.php'; ?>
|
||||||
}
|
|
||||||
code {
|
|
||||||
background: rgba(0,0,0,0.2);
|
|
||||||
padding: 2px 6px;
|
|
||||||
border-radius: 4px;
|
|
||||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
||||||
}
|
|
||||||
footer {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 1rem;
|
|
||||||
font-size: 0.8rem;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<main>
|
|
||||||
<div class="card">
|
|
||||||
<h1>Analyzing your requirements and generating your website…</h1>
|
|
||||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
|
||||||
<span class="sr-only">Loading…</span>
|
|
||||||
</div>
|
|
||||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
|
||||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
|
||||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
<footer>
|
|
||||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
|
||||||
</footer>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
47
item_details.php
Normal file
47
item_details.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?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();
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
<button class="btn btn-primary btn-lg">Rent Now</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php include 'footer.php'; ?>
|
||||||
74
listings.php
Normal file
74
listings.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?php include 'header.php'; ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
// Fetch items from the database
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$location = $_GET['location'] ?? '';
|
||||||
|
|
||||||
|
if (!empty($location)) {
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM items WHERE location LIKE ? ORDER BY created_at DESC");
|
||||||
|
$stmt->execute(["%{$location}%"]);
|
||||||
|
} else {
|
||||||
|
$stmt = $pdo->query("SELECT * FROM items ORDER BY created_at DESC");
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = $stmt->fetchAll();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
// For a real app, you'd log this error and show a user-friendly message
|
||||||
|
$items = [];
|
||||||
|
$db_error = "Database error: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="container section">
|
||||||
|
<h1 class="section-title">Listings</h1>
|
||||||
|
|
||||||
|
<div class="row mb-4">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<form class="search-bar" action="listings.php" method="GET">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" class="form-control form-control-lg search-input" name="location" placeholder="Filter by city, neighborhood, or address..." value="<?php echo htmlspecialchars($location); ?>">
|
||||||
|
<button class="btn btn-light btn-lg search-button" type="submit">
|
||||||
|
<i data-feather="search"></i> Search
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if (isset($db_error)): ?>
|
||||||
|
<div class="alert alert-danger"><?php echo $db_error; ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<?php if (empty($items)): ?>
|
||||||
|
<div class="col">
|
||||||
|
<div class="alert alert-info">No items found.<?php if (!empty($location)) { echo ' for "' . htmlspecialchars($location) . '"'; } ?>. Try a different search or check back later!</div>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php foreach ($items as $item): ?>
|
||||||
|
<div class="col-md-6 col-lg-4 mb-4">
|
||||||
|
<div class="card h-100">
|
||||||
|
<img src="https://images.pexels.com/photos/276583/pexels-photo-276583.jpeg?auto=compress&cs=tinysrgb&w=600" class="card-img-top" alt="<?php echo htmlspecialchars($item['name']); ?>" style="height: 200px; object-fit: cover;">
|
||||||
|
<div class="card-body d-flex flex-column">
|
||||||
|
<h5 class="card-title"><?php echo htmlspecialchars($item['name']); ?></h5>
|
||||||
|
<p class="card-text text-muted"><?php echo htmlspecialchars($item['location']); ?></p>
|
||||||
|
<p class="card-text"><?php echo htmlspecialchars(substr($item['description'], 0, 100)); ?>...</p>
|
||||||
|
<div class="mt-auto d-flex justify-content-between align-items-center">
|
||||||
|
<strong>$<?php echo htmlspecialchars(number_format($item['price_per_day'], 2)); ?> / day</strong>
|
||||||
|
<a href="item_details.php?id=<?php echo htmlspecialchars($item['item_id']); ?>" class="btn btn-primary btn-sm">Rent Now</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<?php include 'footer.php'; ?>
|
||||||
91
login.php
Normal file
91
login.php
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
// If user is already logged in, redirect to dashboard
|
||||||
|
if (isset($_SESSION['user_id'])) {
|
||||||
|
header("Location: dashboard.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$errors = [];
|
||||||
|
$email = '';
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$email = trim($_POST['email']);
|
||||||
|
$password = $_POST['password'];
|
||||||
|
|
||||||
|
if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$errors[] = 'A valid email is required';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($password)) {
|
||||||
|
$errors[] = 'Password is required';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($errors)) {
|
||||||
|
$stmt = db()->prepare("SELECT * FROM users WHERE email = ?");
|
||||||
|
$stmt->execute([$email]);
|
||||||
|
$user = $stmt->fetch();
|
||||||
|
|
||||||
|
if ($user && password_verify($password, $user['password'])) {
|
||||||
|
// Regenerate session ID
|
||||||
|
session_regenerate_id(true);
|
||||||
|
|
||||||
|
// Set session variables
|
||||||
|
$_SESSION['user_id'] = $user['id'];
|
||||||
|
$_SESSION['user_name'] = $user['name'];
|
||||||
|
$_SESSION['user_role'] = $user['role'];
|
||||||
|
|
||||||
|
// Redirect to dashboard
|
||||||
|
header("Location: dashboard.php");
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$errors[] = "Invalid email or password.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<?php include 'header.php'; ?>
|
||||||
|
|
||||||
|
<div class="container mt-5">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h4>Login to your Account</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if (isset($_GET['registered'])): ?>
|
||||||
|
<div class="alert alert-success">
|
||||||
|
Registration successful! Please login.
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (!empty($errors)): ?>
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<?php foreach ($errors as $error): ?>
|
||||||
|
<p><?php echo $error; ?></p>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<form action="login.php" method="POST">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Email Address</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($email); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="password" class="form-label">Password</label>
|
||||||
|
<input type="password" class="form-control" id="password" name="password" required>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary w-100">Login</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer text-center">
|
||||||
|
Don't have an account? <a href="register.php">Sign up here</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php include 'footer.php'; ?>
|
||||||
20
logout.php
Normal file
20
logout.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
// Unset all of the session variables
|
||||||
|
$_SESSION = array();
|
||||||
|
|
||||||
|
// Destroy the session.
|
||||||
|
if (ini_get("session.use_cookies")) {
|
||||||
|
$params = session_get_cookie_params();
|
||||||
|
setcookie(session_name(), '', time() - 42000,
|
||||||
|
$params["path"], $params["domain"],
|
||||||
|
$params["secure"], $params["httponly"]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
session_destroy();
|
||||||
|
|
||||||
|
// Redirect to login page
|
||||||
|
header("Location: login.php?logged_out=true");
|
||||||
|
exit;
|
||||||
102
register.php
Normal file
102
register.php
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$errors = [];
|
||||||
|
$name = '';
|
||||||
|
$email = '';
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$name = trim($_POST['name']);
|
||||||
|
$email = trim($_POST['email']);
|
||||||
|
$password = $_POST['password'];
|
||||||
|
$password_confirm = $_POST['password_confirm'];
|
||||||
|
|
||||||
|
if (empty($name)) {
|
||||||
|
$errors[] = 'Name is required';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$errors[] = 'A valid email is required';
|
||||||
|
} else {
|
||||||
|
$stmt = db()->prepare("SELECT id FROM users WHERE email = ?");
|
||||||
|
$stmt->execute([$email]);
|
||||||
|
if ($stmt->fetch()) {
|
||||||
|
$errors[] = 'Email already in use';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($password)) {
|
||||||
|
$errors[] = 'Password is required';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($password !== $password_confirm) {
|
||||||
|
$errors[] = 'Passwords do not match';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($errors)) {
|
||||||
|
$role = isset($_POST['is_vendor']) && $_POST['is_vendor'] == '1' ? 'vendor' : 'user';
|
||||||
|
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
|
||||||
|
$stmt = db()->prepare("INSERT INTO users (name, email, password, role) VALUES (?, ?, ?, ?)");
|
||||||
|
if ($stmt->execute([$name, $email, $hashed_password, $role])) {
|
||||||
|
// Redirect to login page
|
||||||
|
header("Location: login.php?registered=true");
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$errors[] = "Failed to create account. Please try again.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<?php include 'header.php'; ?>
|
||||||
|
|
||||||
|
<div class="container mt-5">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h4>Create an Account</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if (!empty($errors)): ?>
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<?php foreach ($errors as $error): ?>
|
||||||
|
<p><?php echo $error; ?></p>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<form action="register.php" method="POST">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="name" class="form-label">Full Name</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($name); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Email Address</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($email); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="password" class="form-label">Password</label>
|
||||||
|
<input type="password" class="form-control" id="password" name="password" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="password_confirm" class="form-label">Confirm Password</label>
|
||||||
|
<input type="password" class="form-control" id="password_confirm" name="password_confirm" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-check mb-3">
|
||||||
|
<input class="form-check-input" type="checkbox" value="1" id="is_vendor" name="is_vendor">
|
||||||
|
<label class="form-check-label" for="is_vendor">
|
||||||
|
I want to be a vendor
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary w-100">Register</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer text-center">
|
||||||
|
Already have an account? <a href="login.php">Login here</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php include 'footer.php'; ?>
|
||||||
Loading…
x
Reference in New Issue
Block a user