Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6461eb73ca | ||
|
|
952205e132 | ||
|
|
4f8582c432 | ||
|
|
9e1003f9d1 |
29
api/pexels.php
Normal file
29
api/pexels.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
require_once __DIR__.'/../includes/pexels.php';
|
||||||
|
$qs = isset($_GET['queries']) ? explode(',', $_GET['queries']) : ['woman travel','solo travel','night city','road trip','mountains'];
|
||||||
|
$out = [];
|
||||||
|
foreach ($qs as $q) {
|
||||||
|
$u = 'https://api.pexels.com/v1/search?query=' . urlencode(trim($q)) . '&orientation=portrait&per_page=1&page='.rand(1, 100);
|
||||||
|
$d = pexels_get($u);
|
||||||
|
if ($d && !empty($d['photos'])) {
|
||||||
|
$p = $d['photos'][0];
|
||||||
|
$src = $p['src']['large'] ?? null;
|
||||||
|
$dest = __DIR__.'/../assets/images/pexels/'.$p['id'].'.jpg';
|
||||||
|
if ($src) download_to($src, $dest);
|
||||||
|
$out[] = [
|
||||||
|
'src' => 'assets/images/pexels/'.$p['id'].'.jpg',
|
||||||
|
'photographer' => $p['photographer'] ?? 'Unknown',
|
||||||
|
'photographer_url' => $p['photographer_url'] ?? '',
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
// Fallback: Picsum
|
||||||
|
$out[] = [
|
||||||
|
'src' => 'https://picsum.photos/600/800',
|
||||||
|
'photographer' => 'Random Picsum',
|
||||||
|
'photographer_url' => 'https://picsum.photos/'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo json_encode($out);
|
||||||
|
?>
|
||||||
127
assets/css/custom.css
Normal file
127
assets/css/custom.css
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* HerWay Custom Stylesheet
|
||||||
|
* Palette:
|
||||||
|
* Primary: #E91E63 (Pink)
|
||||||
|
* Secondary: #F8BBD0 (Light Pink)
|
||||||
|
* Background: #FCE4EC (Pale Pink)
|
||||||
|
* Surface: #FFFFFF (White)
|
||||||
|
* Text: #333333 (Dark Gray)
|
||||||
|
*/
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: 'Poppins', sans-serif;
|
||||||
|
color: #333333;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- Typography & Links --- */
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #E91E63;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: #c2185b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- Buttons --- */
|
||||||
|
.btn-primary {
|
||||||
|
background-color: #E91E63;
|
||||||
|
border-color: #E91E63;
|
||||||
|
border-radius: 0.75rem;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
font-weight: 600;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover, .btn-primary:focus {
|
||||||
|
background-color: #c2185b;
|
||||||
|
border-color: #c2185b;
|
||||||
|
box-shadow: 0 4px 15px rgba(233, 30, 99, 0.3);
|
||||||
|
transform: translateY(-2px);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- Header --- */
|
||||||
|
.navbar {
|
||||||
|
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-brand {
|
||||||
|
color: #E91E63 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-link {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- Hero Section --- */
|
||||||
|
.hero-section {
|
||||||
|
padding: 6rem 0;
|
||||||
|
background-image: linear-gradient(to bottom, rgba(252, 228, 236, 0.5), rgba(255, 255, 255, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sos {
|
||||||
|
width: 150px;
|
||||||
|
height: 150px;
|
||||||
|
background-color: #E91E63;
|
||||||
|
color: white;
|
||||||
|
border: 8px solid #F8BBD0;
|
||||||
|
box-shadow: 0 0 0 8px rgba(233, 30, 99, 0.2);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sos .bi {
|
||||||
|
font-size: 3rem;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sos .sos-text {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sos:hover {
|
||||||
|
background-color: #c2185b;
|
||||||
|
color: white;
|
||||||
|
transform: scale(1.05);
|
||||||
|
box-shadow: 0 0 0 12px rgba(233, 30, 99, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- Sections --- */
|
||||||
|
#features .card {
|
||||||
|
border: none;
|
||||||
|
border-radius: 0.75rem;
|
||||||
|
box-shadow: 0 4px 25px rgba(0,0,0,0.08);
|
||||||
|
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
#features .card:hover {
|
||||||
|
transform: translateY(-5px);
|
||||||
|
box-shadow: 0 8px 30px rgba(0,0,0,0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
#features .text-primary {
|
||||||
|
color: #E91E63 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#about .text-primary {
|
||||||
|
color: #E91E63 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg-light {
|
||||||
|
background-color: #fef9fb !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- Footer --- */
|
||||||
|
footer.bg-dark {
|
||||||
|
background-color: #333 !important;
|
||||||
|
}
|
||||||
52
assets/js/main.js
Normal file
52
assets/js/main.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
const sosButton = document.getElementById('sosButton');
|
||||||
|
const sosToastEl = document.getElementById('sosToast');
|
||||||
|
const sosToast = new bootstrap.Toast(sosToastEl);
|
||||||
|
const toastBody = sosToastEl.querySelector('.toast-body');
|
||||||
|
const toastHeader = sosToastEl.querySelector('.toast-header .me-auto');
|
||||||
|
|
||||||
|
if (sosButton) {
|
||||||
|
sosButton.addEventListener('click', function () {
|
||||||
|
// Disable button to prevent multiple clicks
|
||||||
|
sosButton.disabled = true;
|
||||||
|
sosButton.querySelector('.sos-text').textContent = 'Sending...';
|
||||||
|
|
||||||
|
fetch('sos.php', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.success) {
|
||||||
|
toastHeader.classList.remove('text-danger');
|
||||||
|
toastHeader.classList.add('text-success');
|
||||||
|
toastHeader.innerHTML = '<i class="bi bi-check-circle-fill"></i> SOS Sent';
|
||||||
|
toastBody.textContent = data.message;
|
||||||
|
} else {
|
||||||
|
toastHeader.classList.remove('text-success');
|
||||||
|
toastHeader.classList.add('text-danger');
|
||||||
|
toastHeader.innerHTML = '<i class="bi bi-exclamation-triangle-fill"></i> Error';
|
||||||
|
toastBody.textContent = data.message;
|
||||||
|
}
|
||||||
|
sosToast.show();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
toastHeader.classList.remove('text-success');
|
||||||
|
toastHeader.classList.add('text-danger');
|
||||||
|
toastHeader.innerHTML = '<i class="bi bi-exclamation-triangle-fill"></i> Network Error';
|
||||||
|
toastBody.textContent = 'Could not connect to the server. Please check your connection.';
|
||||||
|
sosToast.show();
|
||||||
|
console.error('SOS fetch error:', error);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
// Re-enable the button after a delay
|
||||||
|
setTimeout(() => {
|
||||||
|
sosButton.disabled = false;
|
||||||
|
sosButton.querySelector('.sos-text').textContent = 'SOS';
|
||||||
|
}, 5000); // 5-second cooldown
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
41
db/migrate.php
Normal file
41
db/migrate.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/config.php';
|
||||||
|
|
||||||
|
echo "Starting migration process...\n";
|
||||||
|
|
||||||
|
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, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)");
|
||||||
|
|
||||||
|
// 2. Get all migrations that have been run
|
||||||
|
$ran_migrations_stmt = $pdo->query("SELECT migration FROM migrations");
|
||||||
|
$ran_migrations = $ran_migrations_stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
|
// 3. Get all migration files
|
||||||
|
$migration_files = glob(__DIR__ . '/migrations/*.sql');
|
||||||
|
sort($migration_files);
|
||||||
|
|
||||||
|
$migrations_to_run = array_filter($migration_files, function($file) use ($ran_migrations) {
|
||||||
|
return !in_array(basename($file), $ran_migrations);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (empty($migrations_to_run)) {
|
||||||
|
echo "No new migrations to run.\n";
|
||||||
|
} else {
|
||||||
|
foreach ($migrations_to_run as $file) {
|
||||||
|
echo "Running migration: " . basename($file) . "...\n";
|
||||||
|
$sql = file_get_contents($file);
|
||||||
|
$pdo->exec($sql);
|
||||||
|
|
||||||
|
// 4. Record the migration
|
||||||
|
$stmt = $pdo->prepare("INSERT INTO migrations (migration) VALUES (?)");
|
||||||
|
$stmt->execute([basename($file)]);
|
||||||
|
echo "Migration successful: " . basename($file) . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die("Migration failed: " . $e->getMessage() . "\n");
|
||||||
|
}
|
||||||
10
db/migrations/001_create_users_table.sql
Normal file
10
db/migrations/001_create_users_table.sql
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
-- Create users table
|
||||||
|
CREATE TABLE IF NOT EXISTS `users` (
|
||||||
|
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` VARCHAR(255) NOT NULL,
|
||||||
|
`email` VARCHAR(255) NOT NULL,
|
||||||
|
`password` VARCHAR(255) NOT NULL,
|
||||||
|
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `email` (`email`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
9
db/migrations/002_create_trips_table.sql
Normal file
9
db/migrations/002_create_trips_table.sql
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS trips (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
user_id INT(11) UNSIGNED NOT NULL,
|
||||||
|
destination VARCHAR(255) NOT NULL,
|
||||||
|
trip_time DATETIME NOT NULL,
|
||||||
|
status VARCHAR(50) DEFAULT 'planned',
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
33
includes/footer.php
Normal file
33
includes/footer.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
</main>
|
||||||
|
|
||||||
|
<!-- Footer -->
|
||||||
|
<footer class="py-4 bg-dark text-white">
|
||||||
|
<div class="container text-center">
|
||||||
|
<p>© <?php echo date("Y"); ?> HerWay. All Rights Reserved.</p>
|
||||||
|
<p>
|
||||||
|
<a href="#" class="text-white">Privacy Policy</a> |
|
||||||
|
<a href="#" class="text-white">Terms of Service</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<!-- SOS Toast Notification -->
|
||||||
|
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11">
|
||||||
|
<div id="sosToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||||
|
<div class="toast-header">
|
||||||
|
<strong class="me-auto text-danger"><i class="bi bi-exclamation-triangle-fill"></i> SOS Activated</strong>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="toast-body">
|
||||||
|
Your emergency contacts have been notified and are receiving your live location.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Bootstrap JS -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Custom JS -->
|
||||||
|
<script src="assets/js/main.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
50
includes/header.php
Normal file
50
includes/header.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?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>HerWay - Travel Safe, Together</title>
|
||||||
|
<meta name="description" content="HerWay is a travel safety app for women, providing real-time connections, verified users, and safety features.">
|
||||||
|
|
||||||
|
<!-- Google Fonts: Poppins -->
|
||||||
|
<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=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- Bootstrap CSS -->
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- Bootstrap Icons -->
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||||
|
|
||||||
|
<!-- Custom CSS -->
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<!-- Header -->
|
||||||
|
<header class="navbar navbar-expand-lg navbar-light bg-light sticky-top">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand fw-bold" href="index.php">HerWay</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="index.php#features">Features</a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="index.php#about">About</a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="index.php#contact">Contact</a></li>
|
||||||
|
<?php if (isset($_SESSION['user_id'])): ?>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="my-trips.php">My Trips</a></li>
|
||||||
|
<li class="nav-item"><a class="btn btn-outline-primary ms-lg-3" 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-primary ms-lg-3" href="register.php">Sign Up</a></li>
|
||||||
|
<?php endif; ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
|
||||||
26
includes/pexels.php
Normal file
26
includes/pexels.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
function pexels_key() {
|
||||||
|
$k = getenv('PEXELS_KEY');
|
||||||
|
return $k && strlen($k) > 0 ? $k : 'Vc99rnmOhHhJAbgGQoKLZtsaIVfkeownoQNbTj78VemUjKh08ZYRbf18';
|
||||||
|
}
|
||||||
|
function pexels_get($url) {
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt_array($ch, [
|
||||||
|
CURLOPT_URL => $url,
|
||||||
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
|
CURLOPT_HTTPHEADER => [ 'Authorization: '. pexels_key() ],
|
||||||
|
CURLOPT_TIMEOUT => 15,
|
||||||
|
]);
|
||||||
|
$resp = curl_exec($ch);
|
||||||
|
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
curl_close($ch);
|
||||||
|
if ($code >= 200 && $code < 300 && $resp) return json_decode($resp, true);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
function download_to($srcUrl, $destPath) {
|
||||||
|
$data = file_get_contents($srcUrl);
|
||||||
|
if ($data === false) return false;
|
||||||
|
if (!is_dir(dirname($destPath))) mkdir(dirname($destPath), 0775, true);
|
||||||
|
return file_put_contents($destPath, $data) !== false;
|
||||||
|
}
|
||||||
|
?>
|
||||||
237
index.php
237
index.php
@ -1,150 +1,89 @@
|
|||||||
<?php
|
<?php require_once 'includes/header.php'; ?>
|
||||||
declare(strict_types=1);
|
<!-- Hero Section -->
|
||||||
@ini_set('display_errors', '1');
|
<section class="hero-section text-center">
|
||||||
@error_reporting(E_ALL);
|
<div class="container">
|
||||||
@date_default_timezone_set('UTC');
|
<h1 class="display-4 fw-bold">Travel Safe, Together.</h1>
|
||||||
|
<p class="lead my-4">Connecting women for safer journeys with real-time alerts and a trusted community.</p>
|
||||||
|
<button id="sosButton" class="btn btn-sos btn-lg rounded-circle">
|
||||||
|
<i class="bi bi-shield-lock-fill"></i>
|
||||||
|
<span class="sos-text">SOS</span>
|
||||||
|
</button>
|
||||||
|
<p class="mt-3 text-muted">Press in case of emergency</p>
|
||||||
|
|
||||||
|
<div class="mt-5">
|
||||||
|
<a href="trip-setup.php" class="btn btn-primary btn-lg px-5">Plan a Trip</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
$phpVersion = PHP_VERSION;
|
<!-- Features Section -->
|
||||||
$now = date('Y-m-d H:i:s');
|
<section id="features" class="py-5">
|
||||||
?>
|
<div class="container">
|
||||||
<!doctype html>
|
<h2 class="text-center mb-5">Core Safety Features</h2>
|
||||||
<html lang="en">
|
<div class="row text-center">
|
||||||
<head>
|
<div class="col-md-4 mb-4">
|
||||||
<meta charset="utf-8" />
|
<div class="card h-100">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<div class="card-body">
|
||||||
<title>New Style</title>
|
<i class="bi bi-person-check-fill display-4 text-primary"></i>
|
||||||
<?php
|
<h3 class="h4 mt-3">Verified Users</h3>
|
||||||
// Read project preview data from environment
|
<p>Connect with a community of identity-verified travelers for peace of mind.</p>
|
||||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
</div>
|
||||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
</div>
|
||||||
?>
|
</div>
|
||||||
<?php if ($projectDescription): ?>
|
<div class="col-md-4 mb-4">
|
||||||
<!-- Meta description -->
|
<div class="card h-100">
|
||||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
<div class="card-body">
|
||||||
<!-- Open Graph meta tags -->
|
<i class="bi bi-geo-alt-fill display-4 text-primary"></i>
|
||||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
<h3 class="h4 mt-3">Live Location Sharing</h3>
|
||||||
<!-- Twitter meta tags -->
|
<p>Share your real-time location with trusted contacts when you feel unsafe.</p>
|
||||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
</div>
|
||||||
<?php endif; ?>
|
</div>
|
||||||
<?php if ($projectImageUrl): ?>
|
</div>
|
||||||
<!-- Open Graph image -->
|
<div class="col-md-4 mb-4">
|
||||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
<div class="card h-100">
|
||||||
<!-- Twitter image -->
|
<div class="card-body">
|
||||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
<i class="bi bi-telephone-fill display-4 text-primary"></i>
|
||||||
<?php endif; ?>
|
<h3 class="h4 mt-3">Fake Call Simulation</h3>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<p>Discreetly trigger a fake phone call to deter unwanted interactions.</p>
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
</div>
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
</div>
|
||||||
<style>
|
</div>
|
||||||
:root {
|
</div>
|
||||||
--bg-color-start: #6a11cb;
|
</div>
|
||||||
--bg-color-end: #2575fc;
|
</section>
|
||||||
--text-color: #ffffff;
|
|
||||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
<!-- Inspiration Section -->
|
||||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
<section id="inspiration" class="py-5 bg-light">
|
||||||
}
|
<div class="container">
|
||||||
body {
|
<h2 class="text-center mb-5">Inspiration for Your Next Journey</h2>
|
||||||
margin: 0;
|
<div id="image-gallery" class="row g-4">
|
||||||
font-family: 'Inter', sans-serif;
|
<!-- Images will be loaded here by JavaScript -->
|
||||||
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;
|
<!-- About Section -->
|
||||||
min-height: 100vh;
|
<section id="about" class="py-5 bg-light">
|
||||||
text-align: center;
|
<div class="container">
|
||||||
overflow: hidden;
|
<div class="row align-items-center">
|
||||||
position: relative;
|
<div class="col-md-6">
|
||||||
}
|
<h2>Our Mission</h2>
|
||||||
body::before {
|
<p>HerWay was born from a simple idea: every woman deserves to travel without fear. We are building a platform that empowers women to connect, share journeys, and look out for one another. By combining technology with a trusted community, we aim to make every trip a safer one.</p>
|
||||||
content: '';
|
</div>
|
||||||
position: absolute;
|
<div class="col-md-6 text-center">
|
||||||
top: 0;
|
<!-- Placeholder for an illustration -->
|
||||||
left: 0;
|
<i class="bi bi-heart-fill display-1 text-primary"></i>
|
||||||
width: 100%;
|
</div>
|
||||||
height: 100%;
|
</div>
|
||||||
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>');
|
</div>
|
||||||
animation: bg-pan 20s linear infinite;
|
</section>
|
||||||
z-index: -1;
|
|
||||||
}
|
<!-- Contact Section -->
|
||||||
@keyframes bg-pan {
|
<section id="contact" class="py-5">
|
||||||
0% { background-position: 0% 0%; }
|
<div class="container text-center">
|
||||||
100% { background-position: 100% 100%; }
|
<h2>Get in Touch</h2>
|
||||||
}
|
<p class="lead">Have questions or want to partner with us? We'd love to hear from you.</p>
|
||||||
main {
|
<a href="contact.php" class="btn btn-primary btn-lg">Contact Us</a>
|
||||||
padding: 2rem;
|
</div>
|
||||||
}
|
</section>
|
||||||
.card {
|
<?php require_once 'includes/footer.php'; ?>
|
||||||
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>
|
|
||||||
79
login.php
Normal file
79
login.php
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
// The session is started in header.php
|
||||||
|
require_once 'includes/header.php';
|
||||||
|
|
||||||
|
// If user is already logged in, redirect to trip setup
|
||||||
|
if (isset($_SESSION['user_id'])) {
|
||||||
|
header("Location: trip-setup.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$error_message = '';
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$email = trim($_POST['email']);
|
||||||
|
$password = $_POST['password'];
|
||||||
|
|
||||||
|
if (empty($email) || empty($password)) {
|
||||||
|
$error_message = 'Please fill in all fields.';
|
||||||
|
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$error_message = 'Invalid email format.';
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = :email");
|
||||||
|
$stmt->bindParam(':email', $email, PDO::PARAM_STR);
|
||||||
|
$stmt->execute();
|
||||||
|
$user = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if ($user && password_verify($password, $user['password_hash'])) {
|
||||||
|
// Password is correct, start session
|
||||||
|
$_SESSION['user_id'] = $user['id'];
|
||||||
|
$_SESSION['user_name'] = $user['name'];
|
||||||
|
$_SESSION['user_email'] = $user['email'];
|
||||||
|
header("Location: trip-setup.php");
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
$error_message = 'Invalid email or password.';
|
||||||
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$error_message = "Database error: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="container my-5">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h2 class="card-title text-center mb-4">Login</h2>
|
||||||
|
<?php if (!empty($error_message)): ?>
|
||||||
|
<div class="alert alert-danger"><?php echo htmlspecialchars($error_message); ?></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>
|
||||||
|
<div class="d-grid">
|
||||||
|
<button type="submit" class="btn btn-primary">Login</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer text-center">
|
||||||
|
<p class="mb-0">Don't have an account? <a href="register.php">Sign up here</a>.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php require_once 'includes/footer.php'; ?>
|
||||||
6
logout.php
Normal file
6
logout.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
session_unset();
|
||||||
|
session_destroy();
|
||||||
|
header("Location: index.php");
|
||||||
|
exit();
|
||||||
78
my-trips.php
Normal file
78
my-trips.php
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'db/config.php';
|
||||||
|
require_once 'includes/header.php';
|
||||||
|
|
||||||
|
// Redirect to login if user is not authenticated
|
||||||
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
header('Location: login.php');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$trips = [];
|
||||||
|
$error_message = '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare("SELECT destination, trip_time, status, created_at FROM trips WHERE user_id = :user_id ORDER BY trip_time DESC");
|
||||||
|
$stmt->bindParam(':user_id', $_SESSION['user_id'], PDO::PARAM_INT);
|
||||||
|
$stmt->execute();
|
||||||
|
$trips = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$error_message = 'Database error: ' . $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
$success_message = '';
|
||||||
|
if (isset($_GET['status']) && $_GET['status'] === 'success') {
|
||||||
|
$success_message = 'Your trip has been successfully saved!';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<main class="py-5">
|
||||||
|
<section id="my-trips" class="container">
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
|
<h1 class="h2">My Planned Trips</h1>
|
||||||
|
<a href="trip-setup.php" class="btn btn-primary">Plan a New Trip</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if (!empty($success_message)): ?>
|
||||||
|
<div class="alert alert-success"><?php echo htmlspecialchars($success_message); ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if (!empty($error_message)): ?>
|
||||||
|
<div class="alert alert-danger"><?php echo htmlspecialchars($error_message); ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if (empty($trips)): ?>
|
||||||
|
<p class="text-center text-muted">You have no planned trips yet.</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped table-hover">
|
||||||
|
<thead class="table-light">
|
||||||
|
<tr>
|
||||||
|
<th>Destination</th>
|
||||||
|
<th>Date & Time</th>
|
||||||
|
<th>Status</th>
|
||||||
|
<th>Booked On</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($trips as $trip): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($trip['destination']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars(date('D, M j, Y, g:i A', strtotime($trip['trip_time']))); ?></td>
|
||||||
|
<td><span class="badge bg-primary"><?php echo htmlspecialchars(ucfirst($trip['status'])); ?></span></td>
|
||||||
|
<td><?php echo htmlspecialchars(date('M j, Y', strtotime($trip['created_at']))); ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<?php require_once 'includes/footer.php'; ?>
|
||||||
102
register.php
Normal file
102
register.php
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/db/config.php';
|
||||||
|
require_once 'includes/header.php';
|
||||||
|
|
||||||
|
$errors = [];
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$name = trim($_POST['name']);
|
||||||
|
$email = trim($_POST['email']);
|
||||||
|
$password = $_POST['password'];
|
||||||
|
$confirm_password = $_POST['confirm_password'];
|
||||||
|
|
||||||
|
if (empty($name)) {
|
||||||
|
$errors[] = "Name is required.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$errors[] = "A valid email is required.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($password) || strlen($password) < 8) {
|
||||||
|
$errors[] = "Password must be at least 8 characters long.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($password !== $confirm_password) {
|
||||||
|
$errors[] = "Passwords do not match.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($errors)) {
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare("SELECT id FROM users WHERE email = ?");
|
||||||
|
$stmt->execute([$email]);
|
||||||
|
if ($stmt->fetch()) {
|
||||||
|
$errors[] = "An account with this email already exists.";
|
||||||
|
} else {
|
||||||
|
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare("INSERT INTO users (name, email, password) VALUES (?, ?, ?)");
|
||||||
|
if ($stmt->execute([$name, $email, $hashed_password])) {
|
||||||
|
header("Location: login.php");
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$errors[] = "Something went wrong. Please try again later.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$errors[] = "Database error: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<main class="py-5">
|
||||||
|
<section class="container">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body p-5">
|
||||||
|
<h2 class="card-title text-center mb-4">Create Your Account</h2>
|
||||||
|
|
||||||
|
<?php if (!empty($errors)): ?>
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<?php foreach ($errors as $error): ?>
|
||||||
|
<p class="mb-0"><?php echo htmlspecialchars($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" required value="<?php echo isset($_POST['name']) ? htmlspecialchars($_POST['name']) : '' ?>">
|
||||||
|
</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 value="<?php echo isset($_POST['email']) ? htmlspecialchars($_POST['email']) : '' ?>">
|
||||||
|
</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="confirm_password" class="form-label">Confirm Password</label>
|
||||||
|
<input type="password" class="form-control" id="confirm_password" name="confirm_password" required>
|
||||||
|
</div>
|
||||||
|
<div class="d-grid">
|
||||||
|
<button type="submit" class="btn btn-primary btn-lg">Register</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<p class="text-center mt-4">
|
||||||
|
Already have an account? <a href="login.php">Log In</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<?php require_once 'includes/footer.php'; ?>
|
||||||
40
sos.php
Normal file
40
sos.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once __DIR__ . '/mail/MailService.php';
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$response = ['success' => false, 'message' => 'An unexpected error occurred.'];
|
||||||
|
|
||||||
|
$userName = 'An anonymous user';
|
||||||
|
$userEmail = 'Not provided';
|
||||||
|
|
||||||
|
if (isset($_SESSION['user_id'])) {
|
||||||
|
$userName = $_SESSION['user_name'];
|
||||||
|
$userEmail = $_SESSION['user_email'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$subject = 'SOS Alert Triggered by ' . $userName;
|
||||||
|
$htmlBody = "<p>An SOS alert was triggered by:</p>"
|
||||||
|
. "<ul>"
|
||||||
|
. "<li><strong>Name:</strong> " . htmlspecialchars($userName) . "</li>"
|
||||||
|
. "<li><strong>Email:</strong> " . htmlspecialchars($userEmail) . "</li>"
|
||||||
|
. "<li><strong>Time:</strong> " . date('Y-m-d H:i:s') . " UTC</li>"
|
||||||
|
. "</ul>"
|
||||||
|
. "<p>Please take appropriate action immediately.</p>";
|
||||||
|
$textBody = "SOS Alert from " . $userName . " (" . $userEmail . ") at " . date('Y-m-d H:i:s') . " UTC.";
|
||||||
|
|
||||||
|
// Send the email. If no recipient is set in .env, it will use the default.
|
||||||
|
$result = MailService::sendMail(null, $subject, $htmlBody, $textBody);
|
||||||
|
|
||||||
|
if (!empty($result['success'])) {
|
||||||
|
$response['success'] = true;
|
||||||
|
$response['message'] = 'SOS alert sent successfully. Help is on the way.';
|
||||||
|
} else {
|
||||||
|
// In a real app, you would log this error in more detail.
|
||||||
|
$response['message'] = 'Failed to send SOS alert. Please try again or contact support.';
|
||||||
|
// For debugging, you might want to include the error, but not in production.
|
||||||
|
// $response['error'] = $result['error'];
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($response);
|
||||||
74
trip-setup.php
Normal file
74
trip-setup.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'db/config.php';
|
||||||
|
require_once 'includes/header.php';
|
||||||
|
|
||||||
|
// Redirect to login if user is not authenticated
|
||||||
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
header('Location: login.php');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$error_message = '';
|
||||||
|
$success_message = '';
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$destination = trim($_POST['destination']);
|
||||||
|
$trip_time = trim($_POST['trip_time']);
|
||||||
|
|
||||||
|
if (empty($destination) || empty($trip_time)) {
|
||||||
|
$error_message = 'Please fill in all fields.';
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare("INSERT INTO trips (user_id, destination, trip_time) VALUES (:user_id, :destination, :trip_time)");
|
||||||
|
$stmt->bindParam(':user_id', $_SESSION['user_id'], PDO::PARAM_INT);
|
||||||
|
$stmt->bindParam(':destination', $destination, PDO::PARAM_STR);
|
||||||
|
$stmt->bindParam(':trip_time', $trip_time, PDO::PARAM_STR);
|
||||||
|
|
||||||
|
if ($stmt->execute()) {
|
||||||
|
header('Location: my-trips.php?status=success');
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
$error_message = 'Failed to save the trip. Please try again.';
|
||||||
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$error_message = 'Database error: ' . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<main class="py-5">
|
||||||
|
<section id="trip-setup" class="container">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-lg-8">
|
||||||
|
<div class="card p-4 p-md-5">
|
||||||
|
<h1 class="text-center mb-4">Plan Your Trip</h1>
|
||||||
|
<p class="text-center text-muted mb-5">Enter your destination and travel time to find verified travel companions.</p>
|
||||||
|
|
||||||
|
<?php if (!empty($error_message)): ?>
|
||||||
|
<div class="alert alert-danger"><?php echo htmlspecialchars($error_message); ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<form action="trip-setup.php" method="post">
|
||||||
|
<div class="mb-4">
|
||||||
|
<label for="destination" class="form-label fs-5">Where are you going?</label>
|
||||||
|
<input type="text" class="form-control form-control-lg" id="destination" name="destination" placeholder="e.g., 'Mumbai', 'Delhi Airport Terminal 3'" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<label for="trip_time" class="form-label fs-5">When are you traveling?</label>
|
||||||
|
<input type="datetime-local" class="form-control form-control-lg" id="trip_time" name="trip_time" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-center mt-5">
|
||||||
|
<button type="submit" class="btn btn-primary btn-lg px-5">Save Trip</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<?php require_once 'includes/footer.php'; ?>
|
||||||
Loading…
x
Reference in New Issue
Block a user