This commit is contained in:
Flatlogic Bot 2025-10-17 19:11:06 +00:00
parent c04da7df67
commit 939f985a90
15 changed files with 929 additions and 149 deletions

203
assets/css/custom.css Normal file
View File

@ -0,0 +1,203 @@
/* General Body Styles */
body {
font-family: 'Roboto', sans-serif;
color: #4F4F4F;
background-color: #FFFFFF;
margin: 0;
line-height: 1.6;
}
.container {
width: 90%;
max-width: 1100px;
margin: 0 auto;
}
/* Typography */
h1, h2, h3 {
font-family: 'Poppins', sans-serif;
font-weight: 600;
color: #333;
}
h1 { font-size: 3rem; margin-bottom: 1rem; }
h2 { font-size: 2.2rem; margin-bottom: 1rem; text-align: center;}
/* Header and Navbar */
.navbar {
background: #FFFFFF;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
padding: 1rem 0;
position: sticky;
top: 0;
z-index: 1000;
}
.navbar .container {
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
font-family: 'Poppins', sans-serif;
font-size: 1.5rem;
font-weight: 700;
color: #2F80ED;
text-decoration: none;
}
.nav-links {
list-style: none;
margin: 0;
padding: 0;
display: flex;
align-items: center;
}
.nav-links li {
margin-left: 20px;
}
.nav-links a {
text-decoration: none;
color: #4F4F4F;
font-weight: 500;
transition: color 0.3s ease;
}
.nav-links a:hover {
color: #2F80ED;
}
/* Buttons */
.btn {
padding: 10px 20px;
border-radius: 8px;
text-decoration: none;
font-weight: 500;
transition: all 0.3s ease;
display: inline-block;
border: none;
cursor: pointer;
}
.btn-primary {
background-color: #2F80ED;
color: #FFFFFF;
}
.btn-primary:hover {
background-color: #2D67B2;
}
.btn-secondary {
background-color: #F2F2F2;
color: #333;
}
.btn-secondary:hover {
background-color: #E0E0E0;
}
.btn-lg {
padding: 15px 30px;
font-size: 1.1rem;
}
/* Hero Section */
.hero-section {
background: linear-gradient(to right, #2F80ED, #56CCF2);
color: #FFFFFF;
text-align: center;
padding: 100px 0;
}
.hero-section h1 {
color: #FFFFFF;
font-weight: 700;
}
.hero-section p {
font-size: 1.2rem;
margin-bottom: 2rem;
}
/* Content Sections */
.content-section {
padding: 60px 0;
}
.bg-light {
background-color: #F2F2F2;
}
/* Service Boxes */
.service-boxes {
display: flex;
justify-content: space-around;
gap: 20px;
margin-top: 40px;
}
.service-box {
background: #FFFFFF;
padding: 30px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
text-align: center;
width: 30%;
}
.service-box h3 {
font-size: 1.5rem;
margin-bottom: 1rem;
}
/* Contact Form */
.contact-form {
max-width: 600px;
margin: 40px auto 0;
}
.form-group {
margin-bottom: 1.5rem;
}
.form-control {
width: 100%;
padding: 12px;
border: 1px solid #BDBDBD;
border-radius: 8px;
font-size: 1rem;
}
.form-control:focus {
outline: none;
border-color: #2F80ED;
}
/* Footer */
.footer {
background: #333;
color: #FFFFFF;
text-align: center;
padding: 20px 0;
}
/* Form Messages */
#form-messages .success {
color: #27AE60;
background: #E9F7EF;
padding: 10px;
border-radius: 8px;
margin-bottom: 1rem;
}
#form-messages .error {
color: #EB5757;
background: #FDEEEE;
padding: 10px;
border-radius: 8px;
margin-bottom: 1rem;
}

30
assets/js/main.js Normal file
View File

@ -0,0 +1,30 @@
document.addEventListener('DOMContentLoaded', function() {
const contactForm = document.getElementById('contact-form');
const formMessages = document.getElementById('form-messages');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
const formData = new FormData(contactForm);
fetch('handle_contact.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
formMessages.innerHTML = `<div class="success">${data.message}</div>`;
contactForm.reset();
} else {
formMessages.innerHTML = `<div class="error">${data.message}</div>`;
}
})
.catch(error => {
formMessages.innerHTML = `<div class="error">An error occurred while sending your message. Please try again.</div>`;
console.error('Error:', error);
});
});
}
});

47
contact.php Normal file
View File

@ -0,0 +1,47 @@
<?php
header('Content-Type: application/json');
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/mail/MailService.php';
// Basic validation
if (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['message'])) {
echo json_encode(['success' => false, 'error' => 'Please fill out all fields.']);
exit;
}
if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
echo json_encode(['success' => false, 'error' => 'Invalid email format.']);
exit;
}
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
try {
// 1. Save to database
$pdo = db();
$stmt = $pdo->prepare("INSERT INTO contact_submissions (name, email, message) VALUES (?, ?, ?)");
$stmt->execute([$name, $email, $message]);
// 2. Send email notification
// The recipient can be configured via the MAIL_TO environment variable.
$mailResult = MailService::sendContactMessage($name, $email, $message, null, 'New Miralok Africa Inquiry');
if ($mailResult['success']) {
echo json_encode(['success' => true]);
} else {
// Log error, but don't expose it to the client for security.
error_log('MailService Error: ' . ($mailResult['error'] ?? 'Unknown error'));
// Still return success to the user as the main action (saving the submission) was successful.
echo json_encode(['success' => true, 'warning' => 'Could not send email notification.']);
}
} catch (PDOException $e) {
error_log('Database Error: ' . $e->getMessage());
echo json_encode(['success' => false, 'error' => 'A server error occurred. Please try again later.']);
} catch (Exception $e) {
error_log('General Error: ' . $e->getMessage());
echo json_encode(['success' => false, 'error' => 'A server error occurred. Please try again later.']);
}

52
dashboard.php Normal file
View File

@ -0,0 +1,52 @@
<?php
session_start();
// If the user is not logged in, redirect to the login page.
if (!isset($_SESSION['user_id'])) {
header('Location: login.php?redirected=true');
exit;
}
$userName = $_SESSION['user_name'] ?? 'User';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard - Miralok Africa</title>
<meta name="robots" content="noindex, nofollow">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<!-- Header -->
<?php include './shared/header.php'; ?>
<main class="container mt-5 pt-5">
<div class="p-5 mb-4 bg-light rounded-3">
<div class="container-fluid py-5">
<h1 class="display-5 fw-bold">Welcome, <?php echo htmlspecialchars($userName); ?>!</h1>
<p class="col-md-8 fs-4">This is your dashboard. From here you will be able to manage your profile, vehicles, and applications.</p>
<p>Your role is: <strong><?php echo htmlspecialchars($_SESSION['user_role']); ?></strong></p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h2>Quick Actions</h2>
<p>More content and features will be added here soon.</p>
</div>
</div>
</main>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

View File

@ -1,5 +1,4 @@
<?php <?php
// Generated by setup_mariadb_project.sh — edit as needed.
define('DB_HOST', '127.0.0.1'); define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'app_30972'); define('DB_NAME', 'app_30972');
define('DB_USER', 'app_30972'); define('DB_USER', 'app_30972');
@ -15,3 +14,77 @@ function db() {
} }
return $pdo; return $pdo;
} }
function db_init() {
try {
$pdo = db();
// Contact Submissions Table
$pdo->exec("CREATE TABLE IF NOT EXISTS contact_submissions (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
message TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);");
// Organizations Table
$pdo->exec("CREATE TABLE IF NOT EXISTS Organization (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
type ENUM('Insurer','Financier','OEM','FleetOperator','Partner') NOT NULL,
contactEmail VARCHAR(255),
phone VARCHAR(255),
address TEXT,
website VARCHAR(255),
approved BOOLEAN DEFAULT false,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);");
// Users Table
$pdo->exec("CREATE TABLE IF NOT EXISTS User (
id INT AUTO_INCREMENT PRIMARY KEY,
firstName VARCHAR(255) NOT NULL,
lastName VARCHAR(255),
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
phone VARCHAR(255),
role ENUM('Rider','FleetOperator','Insurer','Financier','OEM','Partner','Support','Admin','Public') NOT NULL,
organizationId INT,
verified BOOLEAN DEFAULT false,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (organizationId) REFERENCES Organization(id) ON DELETE SET NULL
);");
// Fleets Table
$pdo->exec("CREATE TABLE IF NOT EXISTS Fleet (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
organizationId INT,
managerUserId INT,
notes TEXT,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (organizationId) REFERENCES Organization(id) ON DELETE CASCADE,
FOREIGN KEY (managerUserId) REFERENCES User(id) ON DELETE SET NULL
);");
// Vehicles Table
$pdo->exec("CREATE TABLE IF NOT EXISTS Vehicle (
id INT AUTO_INCREMENT PRIMARY KEY,
vin VARCHAR(255) UNIQUE,
model VARCHAR(255) NOT NULL,
licensePlate VARCHAR(255),
ownerUserId INT,
fleetId INT,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (ownerUserId) REFERENCES User(id) ON DELETE SET NULL,
FOREIGN KEY (fleetId) REFERENCES Fleet(id) ON DELETE SET NULL
);");
} catch (PDOException $e) {
die("Database initialization failed: " . $e->getMessage());
}
}
// Run the initialization function to ensure tables exist.
db_init();

View File

@ -0,0 +1,7 @@
CREATE TABLE IF NOT EXISTS `contact_submissions` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(255) NOT NULL,
`email` VARCHAR(255) NOT NULL,
`message` TEXT NOT NULL,
`submitted_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

61
handle_contact.php Normal file
View File

@ -0,0 +1,61 @@
<?php
header('Content-Type: application/json');
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/mail/MailService.php';
$response = ['success' => false, 'message' => 'An unknown error occurred.'];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$message = trim($_POST['message'] ?? '');
if (empty($name) || empty($email) || empty($message)) {
$response['message'] = 'Please fill in all fields.';
echo json_encode($response);
exit;
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$response['message'] = 'Invalid email format.';
echo json_encode($response);
exit;
}
try {
$pdo = db();
$sql = "INSERT INTO contact_submissions (name, email, message) VALUES (?, ?, ?)";
$stmt = $pdo->prepare($sql);
if ($stmt->execute([$name, $email, $message])) {
// Database insert was successful, now send email
$mailResult = MailService::sendContactMessage($name, $email, $message);
if (!empty($mailResult['success'])) {
$response['success'] = true;
$response['message'] = 'Thank you for your message. We will get back to you shortly.';
} else {
// Email failed, but data is saved. This might be a configuration issue.
$response['success'] = true; // Still a success from user's perspective
$response['message'] = 'Thank you for your message. It has been received.';
// Log the email error if possible, e.g., error_log("MailService Error: " . $mailResult['error']);
}
} else {
$response['message'] = 'Error: Could not save your message.';
}
} catch (PDOException $e) {
// Log database error, don't show specific SQL errors to user
error_log($e->getMessage());
$response['message'] = 'A server error occurred. Please try again later.';
} catch (Exception $e) {
error_log($e->getMessage());
$response['message'] = 'An unexpected error occurred. Please try again later.';
}
} else {
$response['message'] = 'Invalid request method.';
}
echo json_encode($response);
?>

40
handle_login.php Normal file
View File

@ -0,0 +1,40 @@
<?php
header('Content-Type: application/json');
session_start();
require_once __DIR__ . '/db/config.php';
// 1. Validation
if (empty($_POST['email']) || empty($_POST['password'])) {
echo json_encode(['success' => false, 'error' => 'Email and password are required.']);
exit;
}
$email = $_POST['email'];
$password = $_POST['password'];
try {
$pdo = db();
// 2. Fetch user by email
$stmt = $pdo->prepare("SELECT id, firstName, role, password FROM User WHERE email = ?");
$stmt->execute([$email]);
$user = $stmt->fetch();
// 3. Verify password
if ($user && password_verify($password, $user['password'])) {
// 4. Set session variables
$_SESSION['user_id'] = $user['id'];
$_SESSION['user_name'] = $user['firstName'];
$_SESSION['user_role'] = $user['role'];
echo json_encode(['success' => true, 'redirect' => 'dashboard.php']);
} else {
echo json_encode(['success' => false, 'error' => 'Invalid email or password.']);
}
} catch (PDOException $e) {
error_log('Login Error: ' . $e->getMessage());
echo json_encode(['success' => false, 'error' => 'A server error occurred. Please try again later.']);
}

52
handle_register.php Normal file
View File

@ -0,0 +1,52 @@
<?php
header('Content-Type: application/json');
require_once __DIR__ . '/db/config.php';
// 1. Validation
$errors = [];
if (empty($_POST['firstName'])) { $errors[] = 'First name is required.'; }
if (empty($_POST['lastName'])) { $errors[] = 'Last name is required.'; }
if (empty($_POST['email'])) { $errors[] = 'Email is required.'; }
if (!empty($_POST['email']) && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { $errors[] = 'Invalid email format.'; }
if (empty($_POST['password'])) { $errors[] = 'Password is required.'; }
if (!empty($_POST['password']) && strlen($_POST['password']) < 8) { $errors[] = 'Password must be at least 8 characters long.'; }
if ($_POST['password'] !== $_POST['confirmPassword']) { $errors[] = 'Passwords do not match.'; }
if (!empty($errors)) {
echo json_encode(['success' => false, 'error' => implode(' ', $errors)]);
exit;
}
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$email = $_POST['email'];
$password = $_POST['password'];
try {
$pdo = db();
// 2. Check if user already exists
$stmt = $pdo->prepare("SELECT id FROM User WHERE email = ?");
$stmt->execute([$email]);
if ($stmt->fetch()) {
echo json_encode(['success' => false, 'error' => 'An account with this email already exists.']);
exit;
}
// 3. Hash password
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
// 4. Insert new user with 'Rider' role
$stmt = $pdo->prepare(
"INSERT INTO User (firstName, lastName, email, password, role) VALUES (?, ?, ?, ?, ?)"
);
$stmt->execute([$firstName, $lastName, $email, $hashedPassword, 'Rider']);
// 5. Return success
echo json_encode(['success' => true]);
} catch (PDOException $e) {
error_log('Registration Error: ' . $e->getMessage());
echo json_encode(['success' => false, 'error' => 'A server error occurred during registration. Please try again later.']);
}

205
index.php
View File

@ -1,150 +1,61 @@
<?php <?php include 'shared/header.php'; ?>
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
$phpVersion = PHP_VERSION; <section id="hero" class="hero-section">
$now = date('Y-m-d H:i:s'); <div class="container">
?> <h1>Connecting the Future of African Mobility</h1>
<!doctype html> <p>A unified online ecosystem for electric vehicle adoption, financing, and insurance.</p>
<html lang="en"> <a href="/register.php" class="btn btn-primary btn-lg">Get Started Today</a>
<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> </div>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p> </section>
<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> <section id="about" class="content-section">
<div class="container">
<h2>About Miralok Africa</h2>
<p>Miralok Africa provides online business services that connect riders, fleet operators, insurers, and financiers. We serve as a continental web portal offering verified information, strategic partnerships, and digital workflows that simplify how Africans access, finance, and protect electric mobility assets.</p>
</div> </div>
</main> </section>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC) <section id="services" class="content-section bg-light">
</footer> <div class="container">
</body> <h2>Our Services</h2>
</html> <div class="service-boxes">
<div class="service-box">
<h3>Educate</h3>
<p>We educate the public on EV technology, financing models, and cost-of-ownership.</p>
</div>
<div class="service-box">
<h3>Connect</h3>
<p>We connect insurers, OEMs, and fleet managers for transparent collaboration.</p>
</div>
<div class="service-box">
<h3>Host</h3>
<p>We host digital information, forms, and partner dashboards to reduce time and cost of adoption.</p>
</div>
</div>
</div>
</section>
<section id="contact" class="content-section">
<div class="container">
<h2>Contact Us</h2>
<p>Have a question or want to partner with us? Send us a message.</p>
<form id="contact-form" class="contact-form">
<div id="form-messages"></div>
<div class="form-group">
<label for="name">Name</label>
<input type="text" id="name" name="name" class="form-control" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" name="email" class="form-control" required>
</div>
<div class="form-group">
<label for="message">Message</label>
<textarea id="message" name="message" class="form-control" rows="5" required></textarea>
</div>
<button type="submit" class="btn btn-primary">Send Message</button>
</form>
</div>
</section>
<?php include 'shared/footer.php'; ?>

118
login.php Normal file
View File

@ -0,0 +1,118 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - Miralok Africa</title>
<meta name="robots" content="noindex, nofollow">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<style>
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background-color: var(--surface);
}
.form-container {
background: var(--white);
padding: 3rem;
border-radius: var(--border-radius);
box-shadow: 0 8px 20px rgba(0,0,0,0.08);
width: 100%;
max-width: 450px;
}
</style>
</head>
<body>
<div class="form-container">
<h2 class="text-center mb-4">Log In</h2>
<?php if (isset($_GET['registered']) && $_GET['registered'] === 'true'): ?>
<div class="alert alert-success">Registration successful! Please log in.</div>
<?php endif; ?>
<form id="loginForm" action="handle_login.php" method="POST">
<div id="alert-container"></div>
<?php if (isset($_GET['registered']) && $_GET['registered'] === 'true'): ?>
<div class="alert alert-success">Registration successful! Please log in.</div>
<?php endif; ?>
<?php if (isset($_GET['redirected']) && $_GET['redirected'] === 'true'): ?>
<div class="alert alert-warning">Please log in to access that page.</div>
<?php endif; ?>
<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 btn-lg">Log In</button>
</div>
<p class="text-center mt-3">Don't have an account? <a href="register.php">Register</a></p>
</form>
<p class="text-center mt-4"><a href="/">Back to Home</a></p>
</div>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script>
document.getElementById('loginForm').addEventListener('submit', function(e) {
e.preventDefault();
const form = e.target;
const alertContainer = document.getElementById('alert-container');
const submitBtn = form.querySelector('button[type="submit"]');
alertContainer.innerHTML = '';
const originalBtnText = submitBtn.innerHTML;
submitBtn.disabled = true;
submitBtn.innerHTML = `<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Logging In...`;
const formData = new FormData(form);
fetch(form.action, {
method: 'POST',
body: formData
})
.then(res => res.json())
.then(data => {
if (data.success) {
window.location.href = data.redirect || 'dashboard.php';
} else {
showAlert(data.error || 'An unknown error occurred.', 'danger');
}
})
.catch(err => {
showAlert('Could not connect to the server. Please try again later.', 'danger');
})
.finally(() => {
submitBtn.disabled = false;
submitBtn.innerHTML = originalBtnText;
});
});
function showAlert(message, type) {
const alertContainer = document.getElementById('alert-container');
const wrapper = document.createElement('div');
wrapper.innerHTML = [
`<div class="alert alert-${type} alert-dismissible" role="alert">`,
` <div>${message}</div>`,
' <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>',
'</div>'
].join('');
alertContainer.append(wrapper);
}
</script>
</body>
</html>

22
logout.php Normal file
View File

@ -0,0 +1,22 @@
<?php
session_start();
// Unset all of the session variables.
$_SESSION = [];
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
// Finally, destroy the session.
session_destroy();
// Redirect to homepage.
header('Location: index.php');
exit;

127
register.php Normal file
View File

@ -0,0 +1,127 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Register - Miralok Africa</title>
<meta name="robots" content="noindex, nofollow">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<style>
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background-color: var(--surface);
}
.form-container {
background: var(--white);
padding: 3rem;
border-radius: var(--border-radius);
box-shadow: 0 8px 20px rgba(0,0,0,0.08);
width: 100%;
max-width: 500px;
}
</style>
</head>
<body>
<div class="form-container">
<h2 class="text-center mb-4">Create Your Rider Account</h2>
<div id="alert-container"></div>
<form id="registerForm" action="handle_register.php" method="POST">
<div class="row">
<div class="col-md-6 mb-3">
<label for="firstName" class="form-label">First Name</label>
<input type="text" class="form-control" id="firstName" name="firstName" required>
</div>
<div class="col-md-6 mb-3">
<label for="lastName" class="form-label">Last Name</label>
<input type="text" class="form-control" id="lastName" name="lastName" required>
</div>
</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" required minlength="8">
</div>
<div class="mb-3">
<label for="confirmPassword" class="form-label">Confirm Password</label>
<input type="password" class="form-control" id="confirmPassword" name="confirmPassword" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary btn-lg">Register</button>
</div>
<p class="text-center mt-3">Already have an account? <a href="login.php">Log in</a></p>
</form>
<p class="text-center mt-4"><a href="/">Back to Home</a></p>
</div>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script>
document.getElementById('registerForm').addEventListener('submit', function(e) {
e.preventDefault();
const form = e.target;
const password = form.password.value;
const confirmPassword = form.confirmPassword.value;
const alertContainer = document.getElementById('alert-container');
const submitBtn = form.querySelector('button[type="submit"]');
alertContainer.innerHTML = '';
if (password !== confirmPassword) {
showAlert('Passwords do not match.', 'danger');
return;
}
const originalBtnText = submitBtn.innerHTML;
submitBtn.disabled = true;
submitBtn.innerHTML = `<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Creating Account...`;
const formData = new FormData(form);
fetch(form.action, {
method: 'POST',
body: formData
})
.then(res => res.json())
.then(data => {
if (data.success) {
window.location.href = 'login.php?registered=true';
} else {
showAlert(data.error || 'An unknown error occurred.', 'danger');
}
})
.catch(err => {
showAlert('Could not connect to the server. Please try again later.', 'danger');
})
.finally(() => {
submitBtn.disabled = false;
submitBtn.innerHTML = originalBtnText;
});
});
function showAlert(message, type) {
const alertContainer = document.getElementById('alert-container');
const wrapper = document.createElement('div');
wrapper.innerHTML = [
`<div class="alert alert-${type} alert-dismissible" role="alert">`,
` <div>${message}</div>`,
' <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>',
'</div>'
].join('');
alertContainer.append(wrapper);
}
</script>
</body>
</html>

9
shared/footer.php Normal file
View File

@ -0,0 +1,9 @@
</main>
<footer class="footer">
<div class="container">
<p>&copy; <?php echo date('Y'); ?> Miralok Africa. All Rights Reserved.</p>
</div>
</footer>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>

28
shared/header.php Normal file
View File

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Miralok Africa</title>
<meta name="description" content="Miralok Africa is a continental web portal connecting riders, fleet operators, insurers, and financiers to simplify EV adoption, financing, and insurance.">
<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&family=Roboto:wght@400;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<header class="navbar">
<div class="container">
<a href="/" class="logo">Miralok Africa</a>
<nav>
<ul class="nav-links">
<li><a href="#about">About</a></li>
<li><a href="#services">Services</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="/login.php" class="btn btn-secondary">Login</a></li>
<li><a href="/register.php" class="btn btn-primary">Get Started</a></li>
</ul>
</nav>
</div>
</header>
<main>