Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1609d489f1 | ||
|
|
238c66845b | ||
|
|
363f73447c | ||
|
|
19713d7205 |
138
assets/css/custom.css
Normal file
138
assets/css/custom.css
Normal file
@ -0,0 +1,138 @@
|
||||
/* Google Fonts Import */
|
||||
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700&family=Merriweather:wght@700&display=swap');
|
||||
|
||||
:root {
|
||||
--primary-color: #2A9D8F;
|
||||
--secondary-color: #E9C46A;
|
||||
--background-color: #F4F1DE;
|
||||
--surface-color: #FFFFFF;
|
||||
--text-color: #264653;
|
||||
--heading-font: 'Merriweather', serif;
|
||||
--body-font: 'Lato', sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: var(--body-font);
|
||||
background-color: var(--background-color);
|
||||
color: var(--text-color);
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6, .navbar-brand, .hero-title {
|
||||
font-family: var(--heading-font);
|
||||
}
|
||||
|
||||
.section-title {
|
||||
color: var(--primary-color);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
font-size: 1.75rem;
|
||||
color: var(--primary-color) !important;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
font-weight: 700;
|
||||
transition: color 0.3s;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.hero-section {
|
||||
background: url('https://picsum.photos/seed/community/1600/900') no-repeat center center;
|
||||
background-size: cover;
|
||||
color: white;
|
||||
padding: 10rem 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.hero-section::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.hero-section .container {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.hero-title {
|
||||
font-size: 4rem;
|
||||
font-weight: 700;
|
||||
text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
.hero-subtitle {
|
||||
font-size: 1.5rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.btn {
|
||||
border-radius: 9999px;
|
||||
padding: 0.75rem 2rem;
|
||||
font-weight: 700;
|
||||
border: none;
|
||||
transition: transform 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 8px rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: linear-gradient(45deg, var(--primary-color), #89CDBF);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background-color: var(--secondary-color);
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.hero-cta .btn {
|
||||
margin: 0 0.5rem;
|
||||
}
|
||||
|
||||
.step {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.step h3 {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
#contact form .form-control {
|
||||
border-radius: 0.5rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
footer {
|
||||
background-color: var(--text-color);
|
||||
color: var(--background-color);
|
||||
}
|
||||
|
||||
footer a {
|
||||
color: var(--secondary-color);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
footer a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.img-fluid {
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
17
assets/js/main.js
Normal file
17
assets/js/main.js
Normal file
@ -0,0 +1,17 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Smooth scroll for anchor links
|
||||
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
||||
anchor.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
const targetId = this.getAttribute('href');
|
||||
const targetElement = document.querySelector(targetId);
|
||||
|
||||
if (targetElement) {
|
||||
targetElement.scrollIntoView({
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
41
claim.php
Normal file
41
claim.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
// Ensure user is logged in and is an NGO
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'ngo') {
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check if listing_id is provided
|
||||
if (!isset($_GET['listing_id']) || !is_numeric($_GET['listing_id'])) {
|
||||
header("Location: dashboard.php?error=invalid_listing");
|
||||
exit;
|
||||
}
|
||||
|
||||
$listing_id = $_GET['listing_id'];
|
||||
$ngo_id = $_SESSION['user_id'];
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Check if the listing exists and is available
|
||||
$stmt = $pdo->prepare("SELECT * FROM food_listings WHERE id = ? AND status = 'listed'");
|
||||
$stmt->execute([$listing_id]);
|
||||
$listing = $stmt->fetch();
|
||||
|
||||
if (!$listing) {
|
||||
header("Location: dashboard.php?error=listing_not_available");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Update the listing to mark it as claimed
|
||||
$stmt = $pdo->prepare("UPDATE food_listings SET status = 'claimed', claimed_by_id = ? WHERE id = ?");
|
||||
$success = $stmt->execute([$ngo_id, $listing_id]);
|
||||
|
||||
if ($success) {
|
||||
header("Location: dashboard.php?success=claimed");
|
||||
} else {
|
||||
header("Location: dashboard.php?error=claim_failed");
|
||||
}
|
||||
exit;
|
||||
109
dashboard.php
Normal file
109
dashboard.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
// Ensure user is logged in and is an NGO
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'ngo') {
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
$ngo_id = $_SESSION['user_id'];
|
||||
|
||||
// Fetch available food listings
|
||||
$stmt_available = $pdo->prepare("
|
||||
SELECT fl.*, u.name AS restaurant_name
|
||||
FROM food_listings fl
|
||||
JOIN users u ON fl.user_id = u.id
|
||||
WHERE fl.status = 'listed'
|
||||
ORDER BY fl.pickup_deadline ASC
|
||||
");
|
||||
$stmt_available->execute();
|
||||
$available_listings = $stmt_available->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Fetch listings claimed by the current NGO
|
||||
$stmt_claimed = $pdo->prepare("
|
||||
SELECT fl.*, u.name AS restaurant_name
|
||||
FROM food_listings fl
|
||||
JOIN users u ON fl.user_id = u.id
|
||||
WHERE fl.status = 'claimed' AND fl.claimed_by_id = ?
|
||||
ORDER BY fl.pickup_deadline ASC
|
||||
");
|
||||
$stmt_claimed->execute([$ngo_id]);
|
||||
$claimed_listings = $stmt_claimed->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
?>
|
||||
<?php include 'partials/header.php'; ?>
|
||||
|
||||
<div class="container py-5">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2 class="mb-0">NGO Dashboard</h2>
|
||||
<a href="logout.php" class="btn btn-danger">Logout</a>
|
||||
</div>
|
||||
|
||||
<p>Welcome, <strong><?php echo htmlspecialchars($_SESSION['user_name']); ?></strong>! Here are the current listings.</p>
|
||||
|
||||
<?php if (isset($_GET['success']) && $_GET['success'] == 'claimed'): ?>
|
||||
<div class="alert alert-success">Donation claimed successfully! You can see it in your claimed donations list below.</div>
|
||||
<?php elseif (isset($_GET['error'])): ?>
|
||||
<div class="alert alert-danger">There was an error. The donation might have already been claimed.</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Claimed Listings -->
|
||||
<hr class="my-5">
|
||||
<h3 class="mb-4">My Claimed Donations</h3>
|
||||
<div class="row">
|
||||
<?php if (empty($claimed_listings)): ?>
|
||||
<div class="col-12">
|
||||
<div class="alert alert-secondary">You have not claimed any donations yet.</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($claimed_listings as $listing): ?>
|
||||
<div class="col-md-6 col-lg-4 mb-4">
|
||||
<div class="card h-100 border-primary">
|
||||
<div class="card-header bg-primary text-white">Claimed</div>
|
||||
<div class="card-body d-flex flex-column">
|
||||
<h5 class="card-title"><?php echo htmlspecialchars($listing['title']); ?></h5>
|
||||
<h6 class="card-subtitle mb-2 text-muted">From: <?php echo htmlspecialchars($listing['restaurant_name']); ?></h6>
|
||||
<p class="card-text"><?php echo htmlspecialchars($listing['description']); ?></p>
|
||||
<ul class="list-group list-group-flush mt-auto">
|
||||
<li class="list-group-item"><strong>Pickup By:</strong> <span class="fw-bold"><?php echo date('g:i A, M j', strtotime($listing['pickup_deadline'])); ?></span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Available Listings -->
|
||||
<hr class="my-5">
|
||||
<h3 class="mb-4">Available Food Donations</h3>
|
||||
<div class="row">
|
||||
<?php if (empty($available_listings)): ?>
|
||||
<div class="col-12">
|
||||
<div class="alert alert-info">There are no available food donations at the moment. Please check back later.</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($available_listings as $listing): ?>
|
||||
<div class="col-md-6 col-lg-4 mb-4">
|
||||
<div class="card h-100">
|
||||
<div class="card-body d-flex flex-column">
|
||||
<h5 class="card-title"><?php echo htmlspecialchars($listing['title']); ?></h5>
|
||||
<h6 class="card-subtitle mb-2 text-muted">From: <?php echo htmlspecialchars($listing['restaurant_name']); ?></h6>
|
||||
<p class="card-text"><?php echo htmlspecialchars($listing['description']); ?></p>
|
||||
<ul class="list-group list-group-flush mt-auto">
|
||||
<li class="list-group-item"><strong>Quantity:</strong> <?php echo htmlspecialchars($listing['quantity']); ?></li>
|
||||
<li class="list-group-item"><strong>Pickup By:</strong> <span class="text-danger fw-bold"><?php echo date('g:i A, M j', strtotime($listing['pickup_deadline'])); ?></span></li>
|
||||
</ul>
|
||||
<a href="claim.php?listing_id=<?php echo $listing['id']; ?>" class="btn btn-success mt-3" onclick="return confirm('Are you sure you want to claim this donation?');">Claim Donation</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'partials/footer.php'; ?>
|
||||
36
db/migrate.php
Normal file
36
db/migrate.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/config.php';
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
|
||||
// 1. Create migrations table if it doesn't exist
|
||||
$pdo->exec('CREATE TABLE IF NOT EXISTS migrations (migration VARCHAR(255) PRIMARY KEY)');
|
||||
|
||||
// 2. Get all executed migrations
|
||||
$executedMigrations = $pdo->query('SELECT migration FROM migrations')->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
// 3. Find all migration files
|
||||
$migrationFiles = glob(__DIR__ . '/migrations/*.sql');
|
||||
|
||||
// 4. Determine which migrations to run
|
||||
foreach ($migrationFiles as $file) {
|
||||
$migrationName = basename($file);
|
||||
|
||||
if (!in_array($migrationName, $executedMigrations)) {
|
||||
// 5. Execute the migration
|
||||
$sql = file_get_contents($file);
|
||||
$pdo->exec($sql);
|
||||
|
||||
// 6. Record the migration
|
||||
$stmt = $pdo->prepare('INSERT INTO migrations (migration) VALUES (?)');
|
||||
$stmt->execute([$migrationName]);
|
||||
|
||||
echo "Migration from $migrationName executed successfully.\n";
|
||||
}
|
||||
}
|
||||
echo "All new migrations have been executed.";
|
||||
|
||||
} catch (PDOException $e) {
|
||||
die("Database migration failed: " . $e->getMessage());
|
||||
}
|
||||
6
db/migrations/001_create_users_table.sql
Normal file
6
db/migrations/001_create_users_table.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS `users` (
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`email` VARCHAR(255) NOT NULL UNIQUE,
|
||||
`password` VARCHAR(255) NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
10
db/migrations/002_add_roles_and_details_to_users.sql
Normal file
10
db/migrations/002_add_roles_and_details_to_users.sql
Normal file
@ -0,0 +1,10 @@
|
||||
ALTER TABLE `users`
|
||||
ADD COLUMN `role` VARCHAR(50) NOT NULL AFTER `password`,
|
||||
ADD COLUMN `name` VARCHAR(255) NOT NULL AFTER `role`,
|
||||
ADD COLUMN `address` TEXT NULL AFTER `name`,
|
||||
ADD COLUMN `contact_person` VARCHAR(255) NULL AFTER `address`,
|
||||
ADD COLUMN `license_number` VARCHAR(255) NULL AFTER `contact_person`,
|
||||
ADD COLUMN `registration_number` VARCHAR(255) NULL AFTER `license_number`,
|
||||
ADD COLUMN `areas_served` TEXT NULL AFTER `registration_number`,
|
||||
ADD COLUMN `is_verified` BOOLEAN NOT NULL DEFAULT FALSE AFTER `areas_served`,
|
||||
ADD COLUMN `first_login` BOOLEAN NOT NULL DEFAULT TRUE AFTER `is_verified`;
|
||||
14
db/migrations/003_create_food_listings_table.sql
Normal file
14
db/migrations/003_create_food_listings_table.sql
Normal file
@ -0,0 +1,14 @@
|
||||
CREATE TABLE IF NOT EXISTS `food_listings` (
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`user_id` INT NOT NULL,
|
||||
`title` VARCHAR(255) NOT NULL,
|
||||
`description` TEXT,
|
||||
`quantity` VARCHAR(255),
|
||||
`food_type` VARCHAR(50),
|
||||
`prepared_time` DATETIME,
|
||||
`pickup_deadline` DATETIME,
|
||||
`photo_url` VARCHAR(255),
|
||||
`status` VARCHAR(50) DEFAULT 'listed',
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE
|
||||
);
|
||||
8
db/migrations/004_add_claimed_by_to_listings.sql
Normal file
8
db/migrations/004_add_claimed_by_to_listings.sql
Normal file
@ -0,0 +1,8 @@
|
||||
ALTER TABLE `food_listings` ADD `claimed_by_id` INT(11) NULL DEFAULT NULL AFTER `user_id`,
|
||||
ADD INDEX `fk_claimed_by_user_idx` (`claimed_by_id` ASC);
|
||||
|
||||
ALTER TABLE `food_listings` ADD CONSTRAINT `fk_claimed_by_user`
|
||||
FOREIGN KEY (`claimed_by_id`)
|
||||
REFERENCES `users` (`id`)
|
||||
ON DELETE SET NULL
|
||||
ON UPDATE CASCADE;
|
||||
244
index.php
244
index.php
@ -1,150 +1,96 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
<?php include 'partials/header.php'; ?>
|
||||
|
||||
$phpVersion = PHP_VERSION;
|
||||
$now = date('Y-m-d H:i:s');
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>New Style</title>
|
||||
<?php
|
||||
// Read project preview data from environment
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<?php if ($projectDescription): ?>
|
||||
<!-- Meta description -->
|
||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
||||
<!-- Open Graph meta tags -->
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<!-- Twitter meta tags -->
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<!-- Open Graph image -->
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<!-- Twitter image -->
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
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>');
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
@keyframes bg-pan {
|
||||
0% { background-position: 0% 0%; }
|
||||
100% { background-position: 100% 100%; }
|
||||
}
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.loader {
|
||||
margin: 1.25rem auto 1.25rem;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.hint {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px; height: 1px;
|
||||
padding: 0; margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap; border: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
margin: 0 0 1rem;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
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>
|
||||
<header id="hero" class="hero-section">
|
||||
<div class="container text-center">
|
||||
<h1 class="hero-title">Turn Surplus into Supper.</h1>
|
||||
<p class="hero-subtitle">We connect restaurants with surplus food to NGOs who feed the hungry.</p>
|
||||
<div class="hero-cta">
|
||||
<a href="#ngos" class="btn btn-primary btn-lg">NGOs: Find Food</a>
|
||||
<a href="#restaurants" class="btn btn-secondary btn-lg">Restaurants: Donate Food</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<section id="about" class="py-5">
|
||||
<div class="container">
|
||||
<h2 class="section-title text-center mb-5">How It Works</h2>
|
||||
<div class="row align-items-center">
|
||||
<div class="col-md-6">
|
||||
<img src="https://picsum.photos/seed/process/800/600" class="img-fluid rounded shadow" alt="A graphic illustrating the process: a restaurant lists surplus food, an NGO claims it, and a volunteer delivers it.">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="step">
|
||||
<h3>1. Restaurants List Surplus</h3>
|
||||
<p>Restaurants with unsold, quality food post a listing on our platform instead of throwing it away.</p>
|
||||
</div>
|
||||
<div class="step">
|
||||
<h3>2. NGOs Claim Donations</h3>
|
||||
<p>Verified NGOs in the area receive notifications and can claim the food donations they need.</p>
|
||||
</div>
|
||||
<div class="step">
|
||||
<h3>3. Community Gets Fed</h3>
|
||||
<p>A volunteer picks up the food and delivers it, ensuring it reaches those who need it most.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="ngos" class="py-5 bg-light">
|
||||
<div class="container">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-md-6">
|
||||
<h2 class="section-title mb-4">For NGOs</h2>
|
||||
<p>Access a steady stream of quality food donations from local restaurants. Reduce your operational costs, expand your reach, and focus on what you do best: serving the community.</p>
|
||||
<a href="/signup.php" class="btn btn-primary">Register your NGO</a>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<img src="https://picsum.photos/seed/ngo/800/600" class="img-fluid rounded shadow" alt="A smiling volunteer from an NGO receiving a food donation.">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="restaurants" class="py-5">
|
||||
<div class="container">
|
||||
<div class="row align-items-center flex-row-reverse">
|
||||
<div class="col-md-6">
|
||||
<h2 class="section-title mb-4">For Restaurants</h2>
|
||||
<p>Reduce food waste, gain tax benefits, and build a positive brand image. Donating your surplus food is simple, efficient, and makes a tangible impact in your local community.</p>
|
||||
<a href="/signup.php" class="btn btn-secondary">Register your Restaurant</a>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<img src="https://picsum.photos/seed/restaurant/800/600" class="img-fluid rounded shadow" alt="A chef plating food in a restaurant kitchen, representing food donation.">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="contact" class="py-5 bg-light">
|
||||
<div class="container">
|
||||
<h2 class="section-title text-center mb-5">Get In Touch</h2>
|
||||
<div class="row">
|
||||
<div class="col-md-8 mx-auto">
|
||||
<form>
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Name</label>
|
||||
<input type="text" class="form-control" id="name" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email address</label>
|
||||
<input type="email" class="form-control" id="email" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="message" class="form-label">Message</label>
|
||||
<textarea class="form-control" id="message" rows="5" required></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Send Message</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<?php include 'partials/footer.php'; ?>
|
||||
119
listings.php
Normal file
119
listings.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
// Redirect to login if not logged in or not a restaurant
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'restaurant') {
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$message = '';
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['add_listing'])) {
|
||||
$user_id = $_SESSION['user_id'];
|
||||
$title = $_POST['title'];
|
||||
$description = $_POST['description'];
|
||||
$quantity = $_POST['quantity'];
|
||||
$food_type = $_POST['food_type'];
|
||||
$prepared_time = $_POST['prepared_time'];
|
||||
$pickup_deadline = $_POST['pickup_deadline'];
|
||||
// Photo upload will be handled later
|
||||
|
||||
if (empty($title) || empty($quantity) || empty($prepared_time) || empty($pickup_deadline)) {
|
||||
$message = '<div class="alert alert-danger">Please fill in all required fields.</div>';
|
||||
} else {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("INSERT INTO food_listings (user_id, title, description, quantity, food_type, prepared_time, pickup_deadline) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$user_id, $title, $description, $quantity, $food_type, $prepared_time, $pickup_deadline]);
|
||||
$message = '<div class="alert alert-success">Food listing created successfully!</div>';
|
||||
} catch (PDOException $e) {
|
||||
$message = '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch existing listings for this restaurant
|
||||
$listings = [];
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("SELECT * FROM food_listings WHERE user_id = ? ORDER BY created_at DESC");
|
||||
$stmt->execute([$_SESSION['user_id']]);
|
||||
$listings = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
// Handle error
|
||||
}
|
||||
|
||||
?>
|
||||
<?php include 'partials/header.php'; ?>
|
||||
|
||||
<div class="container py-5">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1>Restaurant Dashboard</h1>
|
||||
<a href="logout.php" class="btn btn-danger">Logout</a>
|
||||
</div>
|
||||
<p class="lead">Welcome, <?php echo htmlspecialchars($_SESSION['user_name']); ?>!</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<h2>Your Food Listings</h2>
|
||||
<?php if (empty($listings)): ?>
|
||||
<p>You haven't posted any food listings yet.</p>
|
||||
<?php else: ?>
|
||||
<div class="list-group">
|
||||
<?php foreach ($listings as $listing): ?>
|
||||
<div class="list-group-item list-group-item-action flex-column align-items-start">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h5 class="mb-1"><?php echo htmlspecialchars($listing['title']); ?></h5>
|
||||
<small>Status: <?php echo htmlspecialchars($listing['status']); ?></small>
|
||||
</div>
|
||||
<p class="mb-1"><?php echo htmlspecialchars($listing['description']); ?></p>
|
||||
<small>Quantity: <?php echo htmlspecialchars($listing['quantity']); ?></small>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>Add New Listing</h2>
|
||||
<?php echo $message; ?>
|
||||
<form action="listings.php" method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="title" class="form-label">Title</label>
|
||||
<input type="text" class="form-control" id="title" name="title" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="description" class="form-label">Description</label>
|
||||
<textarea class="form-control" id="description" name="description" rows="3"></textarea>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="quantity" class="form-label">Quantity (e.g., "Serves 10-15 people")</label>
|
||||
<input type="text" class="form-control" id="quantity" name="quantity" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="food_type" class="form-label">Food Type</label>
|
||||
<select class="form-select" id="food_type" name="food_type">
|
||||
<option value="veg">Vegetarian</option>
|
||||
<option value="non-veg">Non-Vegetarian</option>
|
||||
<option value="halal">Halal</option>
|
||||
<option value="other">Other</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="prepared_time" class="form-label">Time of Preparation</label>
|
||||
<input type="datetime-local" class="form-control" id="prepared_time" name="prepared_time" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="pickup_deadline" class="form-label">Pickup Deadline</label>
|
||||
<input type="datetime-local" class="form-control" id="pickup_deadline" name="pickup_deadline" required>
|
||||
</div>
|
||||
<button type="submit" name="add_listing" class="btn btn-primary">Add Listing</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'partials/footer.php'; ?>
|
||||
94
login.php
Normal file
94
login.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
|
||||
// Extend session lifetime to 30 days
|
||||
ini_set('session.gc_maxlifetime', 30 * 24 * 60 * 60);
|
||||
session_set_cookie_params(30 * 24 * 60 * 60);
|
||||
session_start();
|
||||
|
||||
$errors = [];
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$email = $_POST['email'] ?? '';
|
||||
$password = $_POST['password'] ?? '';
|
||||
|
||||
if (empty($email)) {
|
||||
$errors[] = 'Email is required';
|
||||
}
|
||||
if (empty($password)) {
|
||||
$errors[] = 'Password is required';
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
try {
|
||||
$pdo = db();
|
||||
|
||||
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
|
||||
$stmt->execute([$email]);
|
||||
$user = $stmt->fetch();
|
||||
|
||||
if ($user && password_verify($password, $user['password'])) {
|
||||
$_SESSION['user_id'] = $user['id'];
|
||||
$_SESSION['user_email'] = $user['email'];
|
||||
$_SESSION['user_role'] = $user['role'];
|
||||
|
||||
if ($user['first_login']) {
|
||||
$updateStmt = $pdo->prepare("UPDATE users SET first_login = 0 WHERE id = ?");
|
||||
$updateStmt->execute([$user['id']]);
|
||||
// Here you could redirect to a welcome page, e.g., header("Location: welcome.php");
|
||||
}
|
||||
|
||||
// Role-based redirection
|
||||
switch ($user['role']) {
|
||||
case 'ngo':
|
||||
header("Location: dashboard.php");
|
||||
exit;
|
||||
case 'restaurant':
|
||||
header("Location: listings.php");
|
||||
exit;
|
||||
default:
|
||||
// Default redirect for any other roles
|
||||
header("Location: dashboard.php");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$errors[] = 'Invalid email or password';
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$errors[] = "Database error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php include 'partials/header.php'; ?>
|
||||
|
||||
<div class="container py-5">
|
||||
<div class="row">
|
||||
<div class="col-md-6 mx-auto">
|
||||
<h2 class="text-center mb-4">Login</h2>
|
||||
|
||||
<?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" 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">Login</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'partials/footer.php'; ?>
|
||||
7
logout.php
Normal file
7
logout.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
session_start();
|
||||
session_unset();
|
||||
session_destroy();
|
||||
header("Location: /");
|
||||
exit;
|
||||
?>
|
||||
13
partials/footer.php
Normal file
13
partials/footer.php
Normal file
@ -0,0 +1,13 @@
|
||||
<footer class="py-4 text-center">
|
||||
<div class="container">
|
||||
<p>© <?php echo date("Y"); ?> FoodBridge. All Rights Reserved.</p>
|
||||
<p><a href="/privacy.php">Privacy Policy</a></p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- Bootstrap 5 JS Bundle -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
||||
<!-- Custom JS -->
|
||||
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||
</body>
|
||||
</html>
|
||||
52
partials/header.php
Normal file
52
partials/header.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php session_start(); ?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>FoodBridge - Connecting NGOs and Restaurants</title>
|
||||
<meta name="description" content="FoodBridge is a platform dedicated to connecting NGOs with restaurants to redistribute surplus food and fight hunger.">
|
||||
<meta name="keywords" content="food donation, surplus food, NGO, restaurant, community support, food waste reduction, hunger relief, non-profit, food security, social impact, Built with Flatlogic Generator">
|
||||
<meta property="og:title" content="FoodBridge - Connecting NGOs and Restaurants">
|
||||
<meta property="og:description" content="Join FoodBridge to connect with local partners, reduce food waste, and support your community.">
|
||||
<meta property="og:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? 'https://picsum.photos/seed/social/1200/630'); ?>">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? 'https://picsum.photos/seed/social/1200/630'); ?>">
|
||||
|
||||
<!-- Bootstrap 5 CDN -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
|
||||
<!-- Google Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Lato:wght@400;700&family=Merriweather:wght@700&display=swap" rel="stylesheet">
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light sticky-top">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="/">FoodBridge</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">
|
||||
<li class="nav-item"><a class="nav-link" href="/#about">About</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/#ngos">For NGOs</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/#restaurants">For Restaurants</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/#contact">Contact</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="nav-link" 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="nav-link" href="/signup.php">Sign Up</a></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
18
privacy.php
Normal file
18
privacy.php
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Privacy Policy - FoodBridge</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container py-5">
|
||||
<h1>Privacy Policy</h1>
|
||||
<p>This is a placeholder for the Privacy Policy page.</p>
|
||||
<p>Information regarding data collection, usage, and protection will be detailed here.</p>
|
||||
<a href="/">Return to Home</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
109
signup-ngo.php
Normal file
109
signup-ngo.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
|
||||
$errors = [];
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$email = $_POST['email'] ?? '';
|
||||
$password = $_POST['password'] ?? '';
|
||||
$name = $_POST['name'] ?? '';
|
||||
$address = $_POST['address'] ?? '';
|
||||
$contact_person = $_POST['contact_person'] ?? '';
|
||||
$registration_number = $_POST['registration_number'] ?? '';
|
||||
$areas_served = $_POST['areas_served'] ?? '';
|
||||
|
||||
// --- Validation ---
|
||||
if (empty($email)) { $errors[] = 'Email is required'; }
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors[] = 'Invalid email format'; }
|
||||
if (empty($password)) { $errors[] = 'Password is required'; }
|
||||
if (strlen($password) < 8) { $errors[] = 'Password must be at least 8 characters long'; }
|
||||
if (empty($name)) { $errors[] = 'NGO name is required'; }
|
||||
if (empty($address)) { $errors[] = 'Address is required'; }
|
||||
if (empty($contact_person)) { $errors[] = 'Contact person is required'; }
|
||||
if (empty($registration_number)) { $errors[] = 'Registration number is required'; }
|
||||
if (empty($areas_served)) { $errors[] = 'Areas served is required'; }
|
||||
|
||||
// Check if email already exists
|
||||
if (empty($errors)) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("SELECT id FROM users WHERE email = ?");
|
||||
$stmt->execute([$email]);
|
||||
if ($stmt->fetch()) {
|
||||
$errors[] = 'Email address is already registered';
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$errors[] = "Database error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
try {
|
||||
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare(
|
||||
"INSERT INTO users (email, password, role, name, address, contact_person, registration_number, areas_served) VALUES (?, ?, 'ngo', ?, ?, ?, ?, ?)"
|
||||
);
|
||||
$stmt->execute([$email, $hashed_password, $name, $address, $contact_person, $registration_number, $areas_served]);
|
||||
|
||||
// Redirect to login page on success
|
||||
header("Location: login.php?registration=success");
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
$errors[] = "Database error on registration: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php include 'partials/header.php'; ?>
|
||||
|
||||
<div class="container py-5">
|
||||
<div class="row">
|
||||
<div class="col-md-8 mx-auto">
|
||||
<h2 class="text-center mb-4">NGO Registration</h2>
|
||||
|
||||
<?php if (!empty($errors)):
|
||||
?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p><?php echo htmlspecialchars($error); ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form action="signup-ngo.php" method="post">
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">NGO Name</label>
|
||||
<input type="text" class="form-control" id="name" name="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" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">Password</label>
|
||||
<input type="password" class="form-control" id="password" name="password" minlength="8" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="address" class="form-label">Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="3" required></textarea>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="contact_person" class="form-label">Contact Person</label>
|
||||
<input type="text" class="form-control" id="contact_person" name="contact_person" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="registration_number" class="form-label">Registration Number</label>
|
||||
<input type="text" class="form-control" id="registration_number" name="registration_number" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="areas_served" class="form-label">Areas Served</label>
|
||||
<input type="text" class="form-control" id="areas_served" name="areas_served" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Register</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'partials/footer.php'; ?>
|
||||
103
signup-restaurant.php
Normal file
103
signup-restaurant.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
|
||||
$errors = [];
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$email = $_POST['email'] ?? '';
|
||||
$password = $_POST['password'] ?? '';
|
||||
$name = $_POST['name'] ?? '';
|
||||
$address = $_POST['address'] ?? '';
|
||||
$contact_person = $_POST['contact_person'] ?? '';
|
||||
$license_number = $_POST['license_number'] ?? '';
|
||||
|
||||
// --- Validation ---
|
||||
if (empty($email)) { $errors[] = 'Email is required'; }
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors[] = 'Invalid email format'; }
|
||||
if (empty($password)) { $errors[] = 'Password is required'; }
|
||||
if (strlen($password) < 8) { $errors[] = 'Password must be at least 8 characters long'; }
|
||||
if (empty($name)) { $errors[] = 'Restaurant name is required'; }
|
||||
if (empty($address)) { $errors[] = 'Address is required'; }
|
||||
if (empty($contact_person)) { $errors[] = 'Contact person is required'; }
|
||||
if (empty($license_number)) { $errors[] = 'Food license number is required'; }
|
||||
|
||||
// Check if email already exists
|
||||
if (empty($errors)) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("SELECT id FROM users WHERE email = ?");
|
||||
$stmt->execute([$email]);
|
||||
if ($stmt->fetch()) {
|
||||
$errors[] = 'Email address is already registered';
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$errors[] = "Database error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
try {
|
||||
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare(
|
||||
"INSERT INTO users (email, password, role, name, address, contact_person, license_number) VALUES (?, ?, 'restaurant', ?, ?, ?, ?)"
|
||||
);
|
||||
$stmt->execute([$email, $hashed_password, $name, $address, $contact_person, $license_number]);
|
||||
|
||||
// Redirect to login page on success
|
||||
header("Location: login.php?registration=success");
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
$errors[] = "Database error on registration: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php include 'partials/header.php'; ?>
|
||||
|
||||
<div class="container py-5">
|
||||
<div class="row">
|
||||
<div class="col-md-8 mx-auto">
|
||||
<h2 class="text-center mb-4">Restaurant Registration</h2>
|
||||
|
||||
<?php if (!empty($errors)):
|
||||
?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p><?php echo htmlspecialchars($error); ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form action="signup-restaurant.php" method="post">
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Restaurant Name</label>
|
||||
<input type="text" class="form-control" id="name" name="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" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">Password</label>
|
||||
<input type="password" class="form-control" id="password" name="password" minlength="8" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="address" class="form-label">Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="3" required></textarea>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="contact_person" class="form-label">Contact Person</label>
|
||||
<input type="text" class="form-control" id="contact_person" name="contact_person" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="license_number" class="form-label">Food License Number</label>
|
||||
<input type="text" class="form-control" id="license_number" name="license_number" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Register</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'partials/footer.php'; ?>
|
||||
17
signup.php
Normal file
17
signup.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php include 'partials/header.php'; ?>
|
||||
|
||||
<div class="container py-5">
|
||||
<div class="row">
|
||||
<div class="col-md-8 mx-auto text-center">
|
||||
<h2 class="mb-4">Join FoodBridge</h2>
|
||||
<p class="lead mb-5">Are you a restaurant wanting to donate surplus food, or an NGO ready to distribute it to those in need? Choose your path below to get started.</p>
|
||||
|
||||
<div class="d-grid gap-4 d-md-flex justify-content-md-center">
|
||||
<a href="signup-restaurant.php" class="btn btn-primary btn-lg px-4 gap-3">I'm a Restaurant</a>
|
||||
<a href="signup-ngo.php" class="btn btn-secondary btn-lg px-4">I'm an NGO</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'partials/footer.php'; ?>
|
||||
Loading…
x
Reference in New Issue
Block a user