Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2fd5ee80aa | ||
|
|
d627358851 | ||
|
|
9044377b64 | ||
|
|
32d970208e |
133
admin/dashboard.php
Normal file
133
admin/dashboard.php
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once '../db/config.php'; // Adjusted path for db/config.php
|
||||||
|
|
||||||
|
// Security check: Ensure user is logged in and is an admin
|
||||||
|
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'admin') {
|
||||||
|
// If not an admin, redirect to the login page with an error message
|
||||||
|
$_SESSION['message'] = "You must be an administrator to access this page.";
|
||||||
|
$_SESSION['alert_type'] = 'danger';
|
||||||
|
header("Location: ../login.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch all users from the database
|
||||||
|
$pdo = db_connect();
|
||||||
|
$users = [];
|
||||||
|
if ($pdo) {
|
||||||
|
try {
|
||||||
|
$stmt = $pdo->query("SELECT id, user_role, full_name, id_number, phone_number, garage_name, location, created_at FROM users ORDER BY created_at DESC");
|
||||||
|
$users = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
// In a real app, you would log this error, not display it.
|
||||||
|
$user_list_error = "Error fetching users: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$user_list_error = "Database connection failed.";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Admin Dashboard - MyMech</title>
|
||||||
|
<meta name="robots" content="noindex, nofollow"> <!-- Prevent search engines from indexing the admin page -->
|
||||||
|
|
||||||
|
<!-- Bootstrap 5 CDN -->
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- 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">
|
||||||
|
|
||||||
|
<!-- Custom CSS -->
|
||||||
|
<link rel="stylesheet" href="../assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<!-- Navbar -->
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-navy-blue-darker">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="../index.php"><span class="golden-text">MyMech</span></a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav ms-auto align-items-center">
|
||||||
|
<li class="nav-item">
|
||||||
|
<span class="navbar-text text-white me-3">Welcome, Admin!</span>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="btn btn-outline-golden px-3" href="../logout.php">Logout</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<!-- Admin Dashboard Section -->
|
||||||
|
<section class="admin-dashboard-section">
|
||||||
|
<div class="container-fluid"> <!-- Use fluid container for more space -->
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="dashboard-container">
|
||||||
|
<h2 class="text-center golden-text mb-4">Administrator Dashboard</h2>
|
||||||
|
<p class="text-center mb-5">Manage all registered users in the system.</p>
|
||||||
|
|
||||||
|
<?php if (isset($user_list_error)): ?>
|
||||||
|
<div class="alert alert-danger"><?php echo htmlspecialchars($user_list_error); ?></div>
|
||||||
|
<?php elseif (empty($users)): ?>
|
||||||
|
<div class="alert alert-info">No users have registered yet.</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-dark table-striped table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Role</th>
|
||||||
|
<th>Full Name</th>
|
||||||
|
<th>ID Number</th>
|
||||||
|
<th>Phone</th>
|
||||||
|
<th>Garage/Shop</th>
|
||||||
|
<th>Location</th>
|
||||||
|
<th>Registered On</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($users as $user): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($user['id']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars(ucfirst(str_replace('_', ' ', $user['user_role']))); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($user['full_name']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($user['id_number']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($user['phone_number']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($user['garage_name'] ?? 'N/A'); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($user['location']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars(date("M d, Y H:i", strtotime($user['created_at']))); ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- Footer -->
|
||||||
|
<footer class="footer text-center">
|
||||||
|
<div class="container">
|
||||||
|
<p>© <?php echo date("Y"); ?> MyMech. All Rights Reserved.</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<!-- Bootstrap 5 JS Bundle -->
|
||||||
|
<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?v=<?php echo time(); ?>"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
228
assets/css/custom.css
Normal file
228
assets/css/custom.css
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
/* MyMech Custom Styles */
|
||||||
|
:root {
|
||||||
|
--navy-blue: #001f3f;
|
||||||
|
--navy-blue-darker: #001428;
|
||||||
|
--golden-yellow: #FFD700;
|
||||||
|
--golden-yellow-dark: #F0C400;
|
||||||
|
--off-white: #EFEFEF;
|
||||||
|
--card-bg: #002a54;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: var(--navy-blue);
|
||||||
|
color: var(--off-white);
|
||||||
|
font-family: 'Poppins', sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-dark .navbar-brand {
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.golden-text {
|
||||||
|
background: -webkit-linear-gradient(45deg, var(--golden-yellow), var(--golden-yellow-dark));
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
-webkit-text-fill-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-brand .golden-text {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero {
|
||||||
|
position: relative;
|
||||||
|
padding: 10rem 0;
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: rgba(0, 20, 40, 0.7);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero .container {
|
||||||
|
position: relative;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero h1 {
|
||||||
|
font-size: 3.5rem;
|
||||||
|
font-weight: 700;
|
||||||
|
text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero p {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-golden {
|
||||||
|
background: linear-gradient(45deg, var(--golden-yellow), var(--golden-yellow-dark));
|
||||||
|
border: none;
|
||||||
|
color: var(--navy-blue-darker);
|
||||||
|
font-weight: 600;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
transition: transform 0.2s ease-in-out, box-shadow 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-golden:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-outline-golden {
|
||||||
|
border: 2px solid var(--golden-yellow);
|
||||||
|
color: var(--golden-yellow);
|
||||||
|
font-weight: 600;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
transition: background-color 0.2s ease, color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-outline-golden:hover {
|
||||||
|
background-color: var(--golden-yellow);
|
||||||
|
color: var(--navy-blue-darker);
|
||||||
|
}
|
||||||
|
|
||||||
|
.join-us-section {
|
||||||
|
padding: 5rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.join-us-section h2 {
|
||||||
|
font-weight: 700;
|
||||||
|
margin-bottom: 3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-card {
|
||||||
|
background-color: var(--card-bg);
|
||||||
|
border: 1px solid #003b73;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 2rem;
|
||||||
|
text-align: center;
|
||||||
|
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-card:hover {
|
||||||
|
transform: translateY(-10px);
|
||||||
|
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-card img {
|
||||||
|
width: 100%;
|
||||||
|
height: 200px;
|
||||||
|
object-fit: cover;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-card h3 {
|
||||||
|
color: var(--golden-yellow);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
background-color: var(--navy-blue-darker);
|
||||||
|
padding: 2rem 0;
|
||||||
|
color: #aaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer a {
|
||||||
|
color: #ccc;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer a:hover {
|
||||||
|
color: var(--golden-yellow);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Form Styles */
|
||||||
|
.form-section {
|
||||||
|
padding: 5rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-container {
|
||||||
|
background-color: var(--card-bg);
|
||||||
|
padding: 3rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid #003b73;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-label {
|
||||||
|
color: var(--off-white);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control, .form-select {
|
||||||
|
background-color: #003b73;
|
||||||
|
border: 1px solid #004a8a;
|
||||||
|
color: var(--off-white);
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control:focus, .form-select:focus {
|
||||||
|
background-color: #004a8a;
|
||||||
|
border-color: var(--golden-yellow);
|
||||||
|
box-shadow: 0 0 0 0.25rem rgba(255, 215, 0, 0.25);
|
||||||
|
color: var(--off-white);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control::placeholder {
|
||||||
|
color: #aab;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg-navy-blue-darker {
|
||||||
|
background-color: var(--navy-blue-darker) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Responsive Adjustments */
|
||||||
|
@media (max-width: 991.98px) {
|
||||||
|
.navbar.bg-transparent {
|
||||||
|
background-color: var(--navy-blue-darker) !important;
|
||||||
|
}
|
||||||
|
.navbar-collapse {
|
||||||
|
padding: 1rem 0;
|
||||||
|
}
|
||||||
|
.navbar-nav .btn {
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 767.98px) {
|
||||||
|
.hero {
|
||||||
|
padding: 6rem 0;
|
||||||
|
}
|
||||||
|
.hero h1 {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
}
|
||||||
|
.hero p {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 575.98px) {
|
||||||
|
.hero h1 {
|
||||||
|
font-size: 2.2rem;
|
||||||
|
}
|
||||||
|
.join-us-section {
|
||||||
|
padding: 3rem 0;
|
||||||
|
}
|
||||||
|
.role-card {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
30
assets/js/main.js
Normal file
30
assets/js/main.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Custom JavaScript for MyMech
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
|
||||||
|
// Registration form logic
|
||||||
|
const registrationForm = document.getElementById('registrationForm');
|
||||||
|
if (registrationForm) {
|
||||||
|
const userRole = document.getElementById('user_role');
|
||||||
|
const garageNameField = document.getElementById('garage_name_field');
|
||||||
|
const garageNameInput = document.getElementById('garage_name');
|
||||||
|
|
||||||
|
function toggleGarageNameField() {
|
||||||
|
const selectedRole = userRole.value;
|
||||||
|
if (selectedRole === 'mechanic' || selectedRole === 'shop_owner') {
|
||||||
|
garageNameField.style.display = 'block';
|
||||||
|
garageNameInput.required = true;
|
||||||
|
} else {
|
||||||
|
garageNameField.style.display = 'none';
|
||||||
|
garageNameInput.required = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initial check
|
||||||
|
toggleGarageNameField();
|
||||||
|
|
||||||
|
// Listen for changes
|
||||||
|
userRole.addEventListener('change', toggleGarageNameField);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("MyMech JS loaded");
|
||||||
|
});
|
||||||
@ -1,17 +1,47 @@
|
|||||||
<?php
|
<?php
|
||||||
// Generated by setup_mariadb_project.sh — edit as needed.
|
// db/config.php
|
||||||
define('DB_HOST', '127.0.0.1');
|
|
||||||
define('DB_NAME', 'app_34233');
|
|
||||||
define('DB_USER', 'app_34233');
|
|
||||||
define('DB_PASS', 'b3b671b9-a1a3-4bff-aa00-682f316d944e');
|
|
||||||
|
|
||||||
function db() {
|
// --- Database Credentials ---
|
||||||
static $pdo;
|
// Replace with your actual database credentials
|
||||||
if (!$pdo) {
|
define('DB_HOST', '127.0.0.1');
|
||||||
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
|
define('DB_NAME', 'mymecha'); // Changed from 'default_db'
|
||||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
define('DB_USER', 'root'); // Changed from 'user'
|
||||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
define('DB_PASS', ''); // Assuming empty password for local dev
|
||||||
]);
|
|
||||||
}
|
// --- PDO Connection Function ---
|
||||||
return $pdo;
|
/**
|
||||||
|
* Creates a PDO database connection.
|
||||||
|
*
|
||||||
|
* @return PDO|null A PDO connection object on success, or null on failure.
|
||||||
|
*/
|
||||||
|
function db_connect() {
|
||||||
|
static $pdo = null; // Static variable to hold the connection
|
||||||
|
|
||||||
|
if ($pdo === null) {
|
||||||
|
$dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8mb4';
|
||||||
|
$options = [
|
||||||
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||||
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||||
|
PDO::ATTR_EMULATE_PREPARES => false,
|
||||||
|
];
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Create the database if it doesn't exist
|
||||||
|
$temp_pdo = new PDO('mysql:host=' . DB_HOST, DB_USER, DB_PASS, $options);
|
||||||
|
$temp_pdo->exec("CREATE DATABASE IF NOT EXISTS " . DB_NAME);
|
||||||
|
|
||||||
|
// Now connect to the specific database
|
||||||
|
$pdo = new PDO($dsn, DB_USER, DB_PASS, $options);
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
// In a real application, you would log this error, not display it
|
||||||
|
// For development, it's useful to see the error
|
||||||
|
error_log('Database Connection Error: ' . $e->getMessage());
|
||||||
|
// Return null or handle the error as appropriate for your application
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $pdo;
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
239
index.php
239
index.php
@ -1,131 +1,118 @@
|
|||||||
<?php
|
<!DOCTYPE html>
|
||||||
declare(strict_types=1);
|
|
||||||
@ini_set('display_errors', '1');
|
|
||||||
@error_reporting(E_ALL);
|
|
||||||
@date_default_timezone_set('UTC');
|
|
||||||
|
|
||||||
$phpVersion = PHP_VERSION;
|
|
||||||
$now = date('Y-m-d H:i:s');
|
|
||||||
?>
|
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>New Style</title>
|
<title>MyMech - Your Trusted Auto Care Partner</title>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<meta name="description" content="Find reliable mechanics and genuine spare parts instantly. Get back on the road faster with MyMech.">
|
||||||
<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">
|
<!-- Bootstrap 5 CDN -->
|
||||||
<style>
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
:root {
|
|
||||||
--bg-color-start: #6a11cb;
|
<!-- Google Fonts (Poppins) -->
|
||||||
--bg-color-end: #2575fc;
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
--text-color: #ffffff;
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
|
||||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
|
||||||
}
|
<!-- Custom CSS -->
|
||||||
body {
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
margin: 0;
|
|
||||||
font-family: 'Inter', sans-serif;
|
<!-- Open Graph Meta Tags -->
|
||||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
<meta property="og:title" content="MyMech - Your Trusted Auto Care Partner">
|
||||||
color: var(--text-color);
|
<meta property="og:description" content="Find reliable mechanics and genuine spare parts instantly.">
|
||||||
display: flex;
|
<meta property="og:image" content="https://picsum.photos/seed/mymechanic-og/1200/630">
|
||||||
justify-content: center;
|
<meta property="og:url" content=""> <!-- Add your final URL here -->
|
||||||
align-items: center;
|
<meta property="og:type" content="website">
|
||||||
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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
|
||||||
<div class="card">
|
<!-- Navbar -->
|
||||||
<h1>Analyzing your requirements and generating your website…</h1>
|
<nav class="navbar navbar-expand-lg navbar-dark bg-transparent position-absolute top-0 start-0 w-100" style="z-index: 10;">
|
||||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
<div class="container">
|
||||||
<span class="sr-only">Loading…</span>
|
<a class="navbar-brand" href="#"><span class="golden-text">MyMech</span></a>
|
||||||
</div>
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWiZZy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
<span class="navbar-toggler-icon"></span>
|
||||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
</button>
|
||||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
</div>
|
<ul class="navbar-nav ms-auto align-items-center">
|
||||||
</main>
|
<li class="nav-item mb-2 mb-lg-0 me-lg-2">
|
||||||
<footer>
|
<a class="btn btn-outline-golden px-3" href="login.php">Login</a>
|
||||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
</li>
|
||||||
</footer>
|
<li class="nav-item">
|
||||||
|
<a class="btn btn-golden px-3" href="register.php">Register</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<!-- Hero Section -->
|
||||||
|
<header class="hero" style="background-image: url('https://picsum.photos/seed/mymechanic-hero/1600/900');">
|
||||||
|
<div class="container">
|
||||||
|
<h1 class="display-3">Your Trusted Mechanic, <span class="golden-text">Just a Click Away.</span></h1>
|
||||||
|
<p class="lead">Find reliable mechanics and genuine spare parts instantly. Get back on the road faster.</p>
|
||||||
|
<div class="d-grid gap-2 d-sm-flex justify-content-sm-center">
|
||||||
|
<a href="search.php?type=mechanic" class="btn btn-golden btn-lg px-4 gap-3">Find a Mechanic</a>
|
||||||
|
<a href="search.php?type=shop_owner" class="btn btn-outline-light btn-lg px-4">Find Spare Parts</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Join Us Section -->
|
||||||
|
<section class="join-us-section text-center">
|
||||||
|
<div class="container">
|
||||||
|
<h2 class="golden-text">Join the MyMech Community</h2>
|
||||||
|
<div class="row g-4">
|
||||||
|
<!-- For Drivers -->
|
||||||
|
<div class="col-lg-4 col-md-6">
|
||||||
|
<div class="role-card">
|
||||||
|
<div>
|
||||||
|
<img src="https://picsum.photos/seed/mymechanic-driver/800/600" alt="A person using a smartphone to find directions.">
|
||||||
|
<h3>For Drivers</h3>
|
||||||
|
<p>Get fast, reliable help from trusted mechanics near you. Search for specific services and parts to get exactly what you need.</p>
|
||||||
|
</div>
|
||||||
|
<a href="register.php" class="btn btn-golden mt-3">Sign Up as a Driver</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- For Mechanics -->
|
||||||
|
<div class="col-lg-4 col-md-6">
|
||||||
|
<div class="role-card">
|
||||||
|
<div>
|
||||||
|
<img src="https://picsum.photos/seed/mymechanic-pro/800/600" alt="A professional mechanic working on a car engine.">
|
||||||
|
<h3>For Mechanics</h3>
|
||||||
|
<p>Grow your business by connecting with car owners in your area. List your services and showcase your expertise.</p>
|
||||||
|
</div>
|
||||||
|
<a href="register.php" class="btn btn-golden mt-3">Register Your Garage</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- For Shops -->
|
||||||
|
<div class="col-lg-4 col-md-6">
|
||||||
|
<div class="role-card">
|
||||||
|
<div>
|
||||||
|
<img src="https://picsum.photos/seed/mymechanic-shop/800/600" alt="A well-organized auto spare parts shop.">
|
||||||
|
<h3>For Part Shops</h3>
|
||||||
|
<p>List your inventory and reach a larger audience. Help drivers find the genuine parts they need quickly and easily.</p>
|
||||||
|
</div>
|
||||||
|
<a href="register.php" class="btn btn-golden mt-3">List Your Parts</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- Footer -->
|
||||||
|
<footer class="footer text-center">
|
||||||
|
<div class="container">
|
||||||
|
<p>© <?php echo date("Y"); ?> MyMech. All Rights Reserved.</p>
|
||||||
|
<p>
|
||||||
|
<a href="privacy.php">Privacy Policy</a> | <a href="terms.php">Terms of Service</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<!-- Bootstrap 5 JS Bundle -->
|
||||||
|
<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?v=<?php echo time(); ?>"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
132
login.php
Normal file
132
login.php
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
// Handle login form submission
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$login_identifier = $_POST['login_identifier'] ?? '';
|
||||||
|
$password = $_POST['password'] ?? '';
|
||||||
|
$error = '';
|
||||||
|
|
||||||
|
if (empty($login_identifier) || empty($password)) {
|
||||||
|
$error = "Please enter both your identifier and password.";
|
||||||
|
} else {
|
||||||
|
$pdo = db_connect();
|
||||||
|
if ($pdo) {
|
||||||
|
// Check if the identifier is a phone number or an ID number
|
||||||
|
$sql = "SELECT id, full_name, user_role, password_hash FROM users WHERE phone_number = :identifier OR id_number = :identifier";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute(['identifier' => $login_identifier]);
|
||||||
|
$user = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if ($user && password_verify($password, $user['password_hash'])) {
|
||||||
|
// Password is correct, set session variables
|
||||||
|
$_SESSION['user_id'] = $user['id'];
|
||||||
|
$_SESSION['full_name'] = $user['full_name'];
|
||||||
|
$_SESSION['user_role'] = $user['user_role'];
|
||||||
|
|
||||||
|
// Redirect based on user role
|
||||||
|
if ($user['user_role'] === 'admin') {
|
||||||
|
header("Location: admin/dashboard.php");
|
||||||
|
} else {
|
||||||
|
// For other users, redirect to the main page or a user-specific dashboard
|
||||||
|
header("Location: index.php");
|
||||||
|
}
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
// Invalid credentials
|
||||||
|
$error = "Invalid login credentials. Please try again.";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error = "Database connection failed. Please try again later.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there was an error, store it in the session to display it
|
||||||
|
if ($error) {
|
||||||
|
$_SESSION['message'] = $error;
|
||||||
|
$_SESSION['alert_type'] = 'danger';
|
||||||
|
header("Location: login.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Login - MyMech</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-navy-blue-darker">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="index.php"><span class="golden-text">MyMech</span></a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav ms-auto align-items-center">
|
||||||
|
<li class="nav-item mb-2 mb-lg-0 me-lg-2">
|
||||||
|
<a class="btn btn-outline-golden px-3" href="login.php">Login</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="btn btn-golden px-3" href="register.php">Register</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<main class="container py-5">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-lg-6 col-md-8">
|
||||||
|
<div class="form-container">
|
||||||
|
<h2 class="text-center golden-text mb-4">Login to Your Account</h2>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Display messages if any (e.g., from registration or login errors)
|
||||||
|
if (isset($_SESSION['message'])) {
|
||||||
|
$message = $_SESSION['message'];
|
||||||
|
$alert_type = $_SESSION['alert_type'];
|
||||||
|
echo "<div class='alert alert-{$alert_type} alert-dismissible fade show' role='alert'>";
|
||||||
|
echo htmlspecialchars($message);
|
||||||
|
echo '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>';
|
||||||
|
echo "</div>";
|
||||||
|
// Unset the session variables so they don't persist
|
||||||
|
unset($_SESSION['message']);
|
||||||
|
unset($_SESSION['alert_type']);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<form action="login.php" method="POST">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="login_identifier" class="form-label">Phone Number or National ID</label>
|
||||||
|
<input type="text" class="form-control" id="login_identifier" name="login_identifier" 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-golden btn-lg">Login</button>
|
||||||
|
</div>
|
||||||
|
<p class="text-center mt-4">Don't have an account? <a href="register.php">Register here</a>.</p>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="footer text-center">
|
||||||
|
<div class="container">
|
||||||
|
<p>© <?php echo date("Y"); ?> MyMech. All Rights Reserved.</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
7
logout.php
Normal file
7
logout.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
session_unset();
|
||||||
|
session_destroy();
|
||||||
|
header("Location: login.php");
|
||||||
|
exit();
|
||||||
|
?>
|
||||||
34
privacy.php
Normal file
34
privacy.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Privacy Policy - MyMech</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="index.php"><span class="golden-text">MyMech</span></a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<main class="container py-5">
|
||||||
|
<h2 class="golden-text">Privacy Policy</h2>
|
||||||
|
<p>This page is under construction. Our Privacy Policy will be detailed here.</p>
|
||||||
|
<div class="text-center mt-4">
|
||||||
|
<a href="index.php" class="btn btn-golden">Go Back to Home</a>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="footer text-center">
|
||||||
|
<div class="container">
|
||||||
|
<p>© <?php echo date("Y"); ?> MyMech. All Rights Reserved.</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
232
register.php
Normal file
232
register.php
Normal file
@ -0,0 +1,232 @@
|
|||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Register - MyMech</title>
|
||||||
|
<meta name="description" content="Join MyMech to find reliable mechanics and genuine spare parts.">
|
||||||
|
|
||||||
|
<!-- Bootstrap 5 CDN -->
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- 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">
|
||||||
|
|
||||||
|
<!-- Custom CSS -->
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<!-- Navbar -->
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-navy-blue-darker">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="index.php"><span class="golden-text">MyMech</span></a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav ms-auto align-items-center">
|
||||||
|
<li class="nav-item mb-2 mb-lg-0 me-lg-2">
|
||||||
|
<a class="btn btn-outline-golden px-3" href="login.php">Login</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="btn btn-golden px-3" href="register.php">Register</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<!-- Registration Form Section -->
|
||||||
|
<section class="form-section">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-lg-7 col-md-9">
|
||||||
|
<div class="form-container">
|
||||||
|
<h2 class="text-center golden-text mb-4">Create Your Account</h2>
|
||||||
|
<p class="text-center mb-5">Join our community of drivers, mechanics, and part suppliers.</p>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
session_start(); // Start the session to store messages
|
||||||
|
|
||||||
|
// Display messages if any
|
||||||
|
if (isset($_SESSION['message'])) {
|
||||||
|
$message = $_SESSION['message'];
|
||||||
|
$alert_type = $_SESSION['alert_type'];
|
||||||
|
echo "<div class='alert alert-{$alert_type} alert-dismissible fade show' role='alert'>";
|
||||||
|
echo $message;
|
||||||
|
echo '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>';
|
||||||
|
echo "</div>";
|
||||||
|
// Unset the session variables so they don't persist
|
||||||
|
unset($_SESSION['message']);
|
||||||
|
unset($_SESSION['alert_type']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$pdo = db_connect();
|
||||||
|
$message = '';
|
||||||
|
$error = false;
|
||||||
|
|
||||||
|
if (!$pdo) {
|
||||||
|
$message = "Database connection failed.";
|
||||||
|
$error = true;
|
||||||
|
} else {
|
||||||
|
// Create table if it doesn't exist
|
||||||
|
try {
|
||||||
|
$pdo->exec("CREATE TABLE IF NOT EXISTS users (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
user_role VARCHAR(50) NOT NULL,
|
||||||
|
full_name VARCHAR(255) NOT NULL,
|
||||||
|
id_number VARCHAR(50) NOT NULL UNIQUE,
|
||||||
|
phone_number VARCHAR(50) NOT NULL UNIQUE,
|
||||||
|
garage_name VARCHAR(255),
|
||||||
|
location VARCHAR(255) NOT NULL,
|
||||||
|
password_hash VARCHAR(255) NOT NULL,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;");
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$message = "Error creating table: " . $e->getMessage();
|
||||||
|
$error = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
// --- Form Data ---
|
||||||
|
$user_role = $_POST['user_role'] ?? '';
|
||||||
|
$full_name = $_POST['full_name'] ?? '';
|
||||||
|
$id_number = $_POST['id_number'] ?? '';
|
||||||
|
$phone_number = $_POST['phone_number'] ?? '';
|
||||||
|
$garage_name = ($user_role === 'mechanic' || $user_role === 'shop_owner') ? ($_POST['garage_name'] ?? '') : null;
|
||||||
|
$location = $_POST['location'] ?? '';
|
||||||
|
$password = $_POST['password'] ?? '';
|
||||||
|
$confirm_password = $_POST['confirm_password'] ?? '';
|
||||||
|
|
||||||
|
// --- Validation ---
|
||||||
|
if (empty($user_role) || empty($full_name) || empty($id_number) || empty($phone_number) || empty($location) || empty($password)) {
|
||||||
|
$message = "Please fill in all required fields.";
|
||||||
|
$error = true;
|
||||||
|
} elseif ($password !== $confirm_password) {
|
||||||
|
$message = "Passwords do not match.";
|
||||||
|
$error = true;
|
||||||
|
} else {
|
||||||
|
// Check for existing user (ID number or phone)
|
||||||
|
$stmt = $pdo->prepare("SELECT id FROM users WHERE id_number = ? OR phone_number = ?");
|
||||||
|
$stmt->execute([$id_number, $phone_number]);
|
||||||
|
if ($stmt->fetch()) {
|
||||||
|
$message = "A user with this ID number or phone number already exists.";
|
||||||
|
$error = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Insertion ---
|
||||||
|
if (!$error) {
|
||||||
|
$password_hash = password_hash($password, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
|
$sql = "INSERT INTO users (user_role, full_name, id_number, phone_number, garage_name, location, password_hash) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$stmt->execute([$user_role, $full_name, $id_number, $phone_number, $garage_name, $location, $password_hash]);
|
||||||
|
$_SESSION['message'] = "Registration successful! You can now log in.";
|
||||||
|
$_SESSION['alert_type'] = 'success';
|
||||||
|
header("Location: login.php"); // Redirect to login page on success
|
||||||
|
exit();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
// Check for duplicate entry specifically
|
||||||
|
if ($e->errorInfo[1] == 1062) {
|
||||||
|
$_SESSION['message'] = "A user with this ID number or phone number already exists.";
|
||||||
|
} else {
|
||||||
|
$_SESSION['message'] = "An error occurred during registration. Please try again.";
|
||||||
|
}
|
||||||
|
$_SESSION['alert_type'] = 'danger';
|
||||||
|
header("Location: register.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($error) {
|
||||||
|
$_SESSION['message'] = $message;
|
||||||
|
$_SESSION['alert_type'] = 'danger';
|
||||||
|
header("Location: register.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<form action="register.php" method="POST" id="registrationForm">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="user_role" class="form-label">I am a...</label>
|
||||||
|
<select class="form-select" id="user_role" name="user_role" required>
|
||||||
|
<option value="driver" selected>Car Owner / Driver</option>
|
||||||
|
<option value="mechanic">Mechanic</option>
|
||||||
|
<option value="shop_owner">Spare Part Shop Owner</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="full_name" class="form-label">Full Names (as on National ID)</label>
|
||||||
|
<input type="text" class="form-control" id="full_name" name="full_name" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="id_number" class="form-label">National ID Number</label>
|
||||||
|
<input type="text" class="form-control" id="id_number" name="id_number" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="phone_number" class="form-label">Phone Number</label>
|
||||||
|
<input type="tel" class="form-control" id="phone_number" name="phone_number" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3" id="garage_name_field" style="display: none;">
|
||||||
|
<label for="garage_name" class="form-label">Garage/Shop Name</label>
|
||||||
|
<input type="text" class="form-control" id="garage_name" name="garage_name">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="location" class="form-label">Location / Address</label>
|
||||||
|
<input type="text" class="form-control" id="location" name="location" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="password" class="form-label">Password</label>
|
||||||
|
<input type="password" class="form-control" id="password" name="password" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 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>
|
||||||
|
|
||||||
|
<div class="d-grid">
|
||||||
|
<button type="submit" class="btn btn-golden btn-lg">Register</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- Footer -->
|
||||||
|
<footer class="footer text-center">
|
||||||
|
<div class="container">
|
||||||
|
<p>© <?php echo date("Y"); ?> MyMech. All Rights Reserved.</p>
|
||||||
|
<p>
|
||||||
|
<a href="privacy.php">Privacy Policy</a> | <a href="terms.php">Terms of Service</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<!-- Bootstrap 5 JS Bundle -->
|
||||||
|
<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?v=<?php echo time(); ?>"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
126
search.php
Normal file
126
search.php
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
// Determine the search type from the URL, default to 'mechanic'
|
||||||
|
$search_type = $_GET['type'] ?? 'mechanic';
|
||||||
|
if (!in_array($search_type, ['mechanic', 'shop_owner'])) {
|
||||||
|
$search_type = 'mechanic'; // Default to a safe value
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the page title and search placeholder based on the type
|
||||||
|
$page_title = ($search_type === 'mechanic') ? 'Find a Mechanic' : 'Find Spare Parts';
|
||||||
|
$search_label = ($search_type === 'mechanic') ? 'Search for a mechanic by location' : 'Search for a spare parts shop by location';
|
||||||
|
$search_placeholder = "Enter a city or area...";
|
||||||
|
$user_role_to_find = ($search_type === 'mechanic') ? 'mechanic' : 'shop_owner';
|
||||||
|
|
||||||
|
$results = [];
|
||||||
|
$search_location = '';
|
||||||
|
|
||||||
|
// Handle the search form submission
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$search_location = trim($_POST['location'] ?? '');
|
||||||
|
|
||||||
|
if (!empty($search_location)) {
|
||||||
|
$pdo = db_connect();
|
||||||
|
if ($pdo) {
|
||||||
|
// Query the database for users matching the role and location
|
||||||
|
$sql = "SELECT full_name, phone_number, location, garage_name FROM users WHERE user_role = :user_role AND location LIKE :location";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute([
|
||||||
|
'user_role' => $user_role_to_find,
|
||||||
|
'location' => '%' . $search_location . '%'
|
||||||
|
]);
|
||||||
|
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title><?php echo htmlspecialchars($page_title); ?> - MyMech</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-navy-blue-darker">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="index.php"><span class="golden-text">MyMech</span></a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav ms-auto align-items-center">
|
||||||
|
<?php if (isset($_SESSION['user_id'])): ?>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="<?php echo $_SESSION['user_role'] === 'admin' ? 'admin/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 mb-2 mb-lg-0 me-lg-2">
|
||||||
|
<a class="btn btn-outline-golden px-3" href="login.php">Login</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="btn btn-golden px-3" href="register.php">Register</a>
|
||||||
|
</li>
|
||||||
|
<?php endif; ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<main class="container py-5">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-lg-8 col-md-10">
|
||||||
|
<div class="search-container p-4 rounded">
|
||||||
|
<h2 class="text-center golden-text mb-4"><?php echo htmlspecialchars($page_title); ?></h2>
|
||||||
|
<form action="search.php?type=<?php echo htmlspecialchars($search_type); ?>" method="POST">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="location" class="form-label"><?php echo htmlspecialchars($search_label); ?></label>
|
||||||
|
<input type="text" class="form-control" id="location" name="location" placeholder="<?php echo htmlspecialchars($search_placeholder); ?>" value="<?php echo htmlspecialchars($search_location); ?>">
|
||||||
|
</div>
|
||||||
|
<div class="d-grid">
|
||||||
|
<button type="submit" class="btn btn-golden btn-lg">Search</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if ($_SERVER["REQUEST_METHOD"] == "POST"): ?>
|
||||||
|
<div class="results-container mt-5">
|
||||||
|
<h3 class="golden-text mb-4">Search Results</h3>
|
||||||
|
<?php if (!empty($results)): ?>
|
||||||
|
<div class="row">
|
||||||
|
<?php foreach ($results as $result): ?>
|
||||||
|
<div class="col-md-6 mb-4">
|
||||||
|
<div class="card result-card h-100">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title golden-text"><?php echo htmlspecialchars($result['garage_name'] ?: $result['full_name']); ?></h5>
|
||||||
|
<p class="card-text mb-1"><strong>Location:</strong> <?php echo htmlspecialchars($result['location']); ?></p>
|
||||||
|
<p class="card-text"><strong>Phone:</strong> <?php echo htmlspecialchars($result['phone_number']); ?></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="alert alert-warning" role="alert">
|
||||||
|
No results found for "<?php echo htmlspecialchars($search_location); ?>". Please try a different location.
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="footer text-center">
|
||||||
|
<div class="container">
|
||||||
|
<p>© <?php echo date("Y"); ?> MyMech. All Rights Reserved.</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
34
terms.php
Normal file
34
terms.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Terms of Service - MyMech</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="index.php"><span class="golden-text">MyMech</span></a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<main class="container py-5">
|
||||||
|
<h2 class="golden-text">Terms of Service</h2>
|
||||||
|
<p>This page is under construction. Our Terms of Service will be detailed here.</p>
|
||||||
|
<div class="text-center mt-4">
|
||||||
|
<a href="index.php" class="btn btn-golden">Go Back to Home</a>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="footer text-center">
|
||||||
|
<div class="container">
|
||||||
|
<p>© <?php echo date("Y"); ?> MyMech. All Rights Reserved.</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user