skillrunner
This commit is contained in:
parent
4cd640664e
commit
433bab0f5a
76
add_job.php
Normal file
76
add_job.php
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
require_once __DIR__ . '/db/config.php';
|
||||||
|
|
||||||
|
$response = ['success' => false, 'message' => 'An unknown error occurred.'];
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
// Basic server-side validation
|
||||||
|
$required_fields = ['title', 'description', 'category', 'skills', 'budget', 'deadline'];
|
||||||
|
$errors = [];
|
||||||
|
foreach ($required_fields as $field) {
|
||||||
|
if (empty(trim($_POST[$field]))) {
|
||||||
|
$errors[] = ucfirst($field) . ' is a required field.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($errors)) {
|
||||||
|
$response['message'] = implode(' ', $errors);
|
||||||
|
echo json_encode($response);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = trim($_POST['title']);
|
||||||
|
$description = trim($_POST['description']);
|
||||||
|
$category = trim($_POST['category']);
|
||||||
|
$skills = trim($_POST['skills']);
|
||||||
|
$budget = filter_var($_POST['budget'], FILTER_VALIDATE_FLOAT);
|
||||||
|
$deadline = $_POST['deadline']; // Basic validation, can be improved
|
||||||
|
$client_id = $_POST['client_id'];
|
||||||
|
|
||||||
|
if ($budget === false || $budget <= 0) {
|
||||||
|
$errors[] = 'Please enter a valid budget.';
|
||||||
|
}
|
||||||
|
|
||||||
|
// A simple check for date format, can be made more robust
|
||||||
|
if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $deadline)) {
|
||||||
|
$errors[] = 'Invalid deadline format.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($client_id) || !filter_var($client_id, FILTER_VALIDATE_INT)) {
|
||||||
|
$errors[] = 'Invalid client ID.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($errors)) {
|
||||||
|
$response['message'] = implode(' ', $errors);
|
||||||
|
echo json_encode($response);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Run the migration first to ensure the table exists.
|
||||||
|
$sql_migration = file_get_contents(__DIR__ . '/db/migrations/001_create_jobs_table.sql');
|
||||||
|
if ($sql_migration) {
|
||||||
|
db()->exec($sql_migration);
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = db()->prepare(
|
||||||
|
"INSERT INTO jobs (client_id, title, description, category, skills, budget, deadline) VALUES (?, ?, ?, ?, ?, ?, ?)"
|
||||||
|
);
|
||||||
|
|
||||||
|
$stmt->execute([$client_id, $title, $description, $category, $skills, $budget, $deadline]);
|
||||||
|
|
||||||
|
$response['success'] = true;
|
||||||
|
$response['message'] = 'Job posted successfully!';
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
// In a real app, log this error instead of echoing it.
|
||||||
|
error_log('Database Error: ' . $e->getMessage());
|
||||||
|
$response['message'] = 'Database error occurred. Please try again later.';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$response['message'] = 'Invalid request method.';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($response);
|
||||||
63
apply-for-job.php
Normal file
63
apply-for-job.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
// Redirect to login if not logged in
|
||||||
|
if (!isset($_SESSION['worker_id'])) {
|
||||||
|
header('Location: login.php');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$current_worker_id = $_SESSION['worker_id'];
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$job_id = isset($_POST['job_id']) ? (int)$_POST['job_id'] : 0;
|
||||||
|
$redirect_url = "job-detail.php?id=" . $job_id;
|
||||||
|
|
||||||
|
if ($job_id === 0) {
|
||||||
|
header("Location: jobs.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
// 1. Check if the worker has already applied for this job
|
||||||
|
$stmt_check = $pdo->prepare("SELECT id FROM job_applications WHERE job_id = :job_id AND worker_id = :worker_id");
|
||||||
|
$stmt_check->bindParam(':job_id', $job_id, PDO::PARAM_INT);
|
||||||
|
$stmt_check->bindParam(':worker_id', $current_worker_id, PDO::PARAM_INT);
|
||||||
|
$stmt_check->execute();
|
||||||
|
|
||||||
|
if ($stmt_check->fetch()) {
|
||||||
|
// The worker has already applied
|
||||||
|
header("Location: " . $redirect_url . "&application_status=error");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Insert the new application
|
||||||
|
$stmt_insert = $pdo->prepare("INSERT INTO job_applications (job_id, worker_id, status) VALUES (:job_id, :worker_id, 'pending')");
|
||||||
|
$stmt_insert->bindParam(':job_id', $job_id, PDO::PARAM_INT);
|
||||||
|
$stmt_insert->bindParam(':worker_id', $current_worker_id, PDO::PARAM_INT);
|
||||||
|
|
||||||
|
if ($stmt_insert->execute()) {
|
||||||
|
// Success
|
||||||
|
header("Location: " . $redirect_url . "&application_status=success");
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
// Failure
|
||||||
|
header("Location: " . $redirect_url . "&application_status=error");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
// In a real app, log this error
|
||||||
|
// error_log("Application error: " . $e->getMessage());
|
||||||
|
header("Location: " . $redirect_url . "&application_status=error");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// If accessed directly, redirect to the jobs page
|
||||||
|
header("Location: jobs.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
57
assets/css/custom.css
Normal file
57
assets/css/custom.css
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
:root {
|
||||||
|
--bs-primary: #0052FF;
|
||||||
|
--bs-primary-rgb: 0, 82, 255;
|
||||||
|
--bs-secondary: #F0F6FF;
|
||||||
|
--bs-success: #34C759;
|
||||||
|
--bs-font-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: #F8F9FA;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar {
|
||||||
|
box-shadow: 0 2px 4px rgba(0,0,0,.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-brand {
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
color: var(--bs-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
font-weight: 600;
|
||||||
|
transition: all 0.2s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 4px 12px rgba(var(--bs-primary-rgb), 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
border: 1px solid #EAECEF;
|
||||||
|
border-radius: 0.75rem;
|
||||||
|
box-shadow: 0 4px 6px rgba(0,0,0,.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control, .form-select {
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control:focus, .form-select:focus {
|
||||||
|
border-color: var(--bs-primary);
|
||||||
|
box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-group-text {
|
||||||
|
border-radius: 0.5rem 0 0 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.needs-validation .form-control:invalid,
|
||||||
|
.needs-validation .form-select:invalid {
|
||||||
|
border-color: var(--bs-danger);
|
||||||
|
}
|
||||||
59
assets/js/main.js
Normal file
59
assets/js/main.js
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
// Bootstrap form validation
|
||||||
|
const form = document.querySelector('.needs-validation');
|
||||||
|
if (form) {
|
||||||
|
form.addEventListener('submit', function (event) {
|
||||||
|
if (!form.checkValidity()) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
form.classList.add('was-validated');
|
||||||
|
}, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AJAX form submission for post-job-form
|
||||||
|
const postJobForm = document.getElementById('post-job-form');
|
||||||
|
if (postJobForm) {
|
||||||
|
postJobForm.addEventListener('submit', function (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
if (form.checkValidity()) {
|
||||||
|
const formData = new FormData(postJobForm);
|
||||||
|
const submitButton = postJobForm.querySelector('button[type="submit"]');
|
||||||
|
const originalButtonText = submitButton.innerHTML;
|
||||||
|
|
||||||
|
submitButton.disabled = true;
|
||||||
|
submitButton.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Posting...';
|
||||||
|
|
||||||
|
fetch('add_job.php', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
const confirmationAlert = document.getElementById('confirmation-alert');
|
||||||
|
if (data.success) {
|
||||||
|
postJobForm.reset();
|
||||||
|
postJobForm.classList.remove('was-validated');
|
||||||
|
confirmationAlert.classList.remove('d-none');
|
||||||
|
window.scrollTo(0, 0);
|
||||||
|
} else {
|
||||||
|
// You can implement a more specific error message display here
|
||||||
|
alert('Error: ' + data.message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
alert('An unexpected error occurred. Please try again.');
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
submitButton.disabled = false;
|
||||||
|
submitButton.innerHTML = originalButtonText;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
postJobForm.classList.add('was-validated');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
128
dashboard-client.php
Normal file
128
dashboard-client.php
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
if (!isset($_SESSION['client_id'])) {
|
||||||
|
header("Location: login-client.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$client_id = $_SESSION['client_id'];
|
||||||
|
|
||||||
|
// Fetch jobs posted by the client
|
||||||
|
$sql_jobs = "SELECT * FROM jobs WHERE client_id = ? ORDER BY created_at DESC";
|
||||||
|
$stmt_jobs = db()->prepare($sql_jobs);
|
||||||
|
$stmt_jobs->execute([$client_id]);
|
||||||
|
$jobs = $stmt_jobs->fetchAll();
|
||||||
|
|
||||||
|
// Fetch applications for the client's jobs
|
||||||
|
$sql_apps = "SELECT ja.*, j.title, w.name AS worker_name, w.email AS worker_email
|
||||||
|
FROM job_applications ja
|
||||||
|
JOIN jobs j ON ja.job_id = j.id
|
||||||
|
JOIN workers w ON ja.worker_id = w.id
|
||||||
|
WHERE j.client_id = ?
|
||||||
|
ORDER BY ja.created_at DESC";
|
||||||
|
$stmt_apps = db()->prepare($sql_apps);
|
||||||
|
$stmt_apps->execute([$client_id]);
|
||||||
|
$applications = $stmt_apps->fetchAll();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Client Dashboard - SkillRunner</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="index.php">SkillRunner</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="post-job.php">Post a New Job</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="logout.php">Logout</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<main class="container mt-5">
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
|
<h1>Client Dashboard</h1>
|
||||||
|
<p class="lead">Welcome, <?php echo htmlspecialchars($_SESSION['client_name']); ?>!</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<section class="mb-5">
|
||||||
|
<h2>Your Posted Jobs</h2>
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if (empty($jobs)): ?>
|
||||||
|
<p>You have not posted any jobs yet. <a href="post-job.php">Post one now!</a></p>
|
||||||
|
<?php else: ?>
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
<?php foreach ($jobs as $job): ?>
|
||||||
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||||
|
<a href="job-detail.php?id=<?php echo $job['id']; ?>"><?php echo htmlspecialchars($job['title']); ?></a>
|
||||||
|
<span class="badge bg-secondary"><?php echo date("M d, Y", strtotime($job['created_at'])); ?></span>
|
||||||
|
</li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>Recent Job Applications</h2>
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if (empty($applications)): ?>
|
||||||
|
<p>No applications received yet.</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Job Title</th>
|
||||||
|
<th>Applicant</th>
|
||||||
|
<th>Applicant Email</th>
|
||||||
|
<th>Applied On</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($applications as $app): ?>
|
||||||
|
<tr>
|
||||||
|
<td><a href="job-detail.php?id=<?php echo $app['job_id']; ?>"><?php echo htmlspecialchars($app['title']); ?></a></td>
|
||||||
|
<td><?php echo htmlspecialchars($app['worker_name']); ?></td>
|
||||||
|
<td><a href="mailto:<?php echo htmlspecialchars($app['worker_email']); ?>"><?php echo htmlspecialchars($app['worker_email']); ?></a></td>
|
||||||
|
<td><?php echo date("M d, Y H:i", strtotime($app['created_at'])); ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="text-center mt-5 py-3 bg-light">
|
||||||
|
<p>© <?php echo date("Y"); ?> SkillRunner. All rights reserved.</p>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
114
dashboard.php
Normal file
114
dashboard.php
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
if (!isset($_SESSION['worker_id'])) {
|
||||||
|
header("Location: login.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$worker_id = $_SESSION['worker_id'];
|
||||||
|
|
||||||
|
$sql = "SELECT j.id, j.title, j.budget, ja.applied_at, ja.status
|
||||||
|
FROM job_applications ja
|
||||||
|
JOIN jobs j ON ja.job_id = j.id
|
||||||
|
WHERE ja.worker_id = ?
|
||||||
|
ORDER BY ja.applied_at DESC";
|
||||||
|
|
||||||
|
$stmt = db()->prepare($sql);
|
||||||
|
$stmt->execute([$worker_id]);
|
||||||
|
$applications = $stmt->fetchAll();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>My Dashboard - SkillRunner</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="index.php">SkillRunner</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="jobs.php">Find Work</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="post-job.php">Post a Job</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="dashboard.php">Dashboard</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="logout.php">Logout</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<main class="container mt-5">
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
|
<h1>Welcome, <?php echo htmlspecialchars($_SESSION['worker_name']); ?>!</h1>
|
||||||
|
<a href="jobs.php" class="btn btn-primary">Browse More Jobs</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2 class="mb-3">My Job Applications</h2>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if (empty($applications)): ?>
|
||||||
|
<p class="text-center">You have not applied for any jobs yet.</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover align-middle">
|
||||||
|
<thead class="table-light">
|
||||||
|
<tr>
|
||||||
|
<th>Job Title</th>
|
||||||
|
<th>Budget</th>
|
||||||
|
<th>Date Applied</th>
|
||||||
|
<th>Status</th>
|
||||||
|
<th>Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($applications as $app): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($app['title']); ?></td>
|
||||||
|
<td>$<?php echo htmlspecialchars(number_format($app['budget'], 2)); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars(date('F j, Y', strtotime($app['applied_at']))); ?></td>
|
||||||
|
<td>
|
||||||
|
<span class="badge bg-<?php echo $app['status'] == 'pending' ? 'warning' : 'success'; ?>">
|
||||||
|
<?php echo htmlspecialchars(ucfirst($app['status'])); ?>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="job-detail.php?id=<?php echo $app['id']; ?>" class="btn btn-sm btn-info">View Job</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="text-center mt-5 py-3 bg-light">
|
||||||
|
<p>© <?php echo date("Y"); ?> SkillRunner. All rights reserved.</p>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
15
db/migrations/001_create_jobs_table.sql
Normal file
15
db/migrations/001_create_jobs_table.sql
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
-- 001_create_jobs_table.sql
|
||||||
|
-- This script creates the main 'jobs' table for the SkillRunner platform.
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `jobs` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`title` VARCHAR(255) NOT NULL,
|
||||||
|
`description` TEXT NOT NULL,
|
||||||
|
`category` VARCHAR(100) NOT NULL,
|
||||||
|
`skills` VARCHAR(255) NOT NULL COMMENT 'Comma-separated list of skills',
|
||||||
|
`budget` DECIMAL(10, 2) NOT NULL,
|
||||||
|
`deadline` DATE NOT NULL,
|
||||||
|
`status` VARCHAR(50) NOT NULL DEFAULT 'open' COMMENT 'e.g., open, reserved, in_progress, completed',
|
||||||
|
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
`client_id` INT COMMENT 'Foreign key to users table, can be added later'
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
10
db/migrations/002_create_workers_table.sql
Normal file
10
db/migrations/002_create_workers_table.sql
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
-- db/migrations/002_create_workers_table.sql
|
||||||
|
CREATE TABLE IF NOT EXISTS workers (
|
||||||
|
id INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
name VARCHAR(255) NOT NULL,
|
||||||
|
email VARCHAR(255) NOT NULL,
|
||||||
|
password_hash VARCHAR(255) NOT NULL,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (id),
|
||||||
|
UNIQUE KEY (email)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
11
db/migrations/003_create_job_applications_table.sql
Normal file
11
db/migrations/003_create_job_applications_table.sql
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
-- db/migrations/003_create_job_applications_table.sql
|
||||||
|
CREATE TABLE IF NOT EXISTS job_applications (
|
||||||
|
id INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
job_id INT(11) NOT NULL,
|
||||||
|
worker_id INT(11) NOT NULL,
|
||||||
|
application_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
status ENUM('pending', 'viewed', 'accepted', 'rejected') DEFAULT 'pending',
|
||||||
|
PRIMARY KEY (id),
|
||||||
|
FOREIGN KEY (job_id) REFERENCES jobs(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (worker_id) REFERENCES workers(id) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
2
db/migrations/005_add_password_to_workers.sql
Normal file
2
db/migrations/005_add_password_to_workers.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
ALTER TABLE `workers` ADD `password` VARCHAR(255) NOT NULL;
|
||||||
7
db/migrations/006_create_clients_table.sql
Normal file
7
db/migrations/006_create_clients_table.sql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS clients (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
name VARCHAR(255) NOT NULL,
|
||||||
|
email VARCHAR(255) NOT NULL UNIQUE,
|
||||||
|
password VARCHAR(255) NOT NULL,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
1
db/migrations/007_add_client_id_to_jobs.sql
Normal file
1
db/migrations/007_add_client_id_to_jobs.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE jobs ADD COLUMN client_id INT NOT NULL AFTER id;
|
||||||
213
index.php
213
index.php
@ -1,150 +1,105 @@
|
|||||||
<?php
|
|
||||||
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>
|
<!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" />
|
||||||
<title>New Style</title>
|
<title>SkillRunner - Find & Hire Verified Experts</title>
|
||||||
<?php
|
<?php
|
||||||
// Read project preview data from environment
|
// Read project preview data from environment
|
||||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'SkillRunner is a trust-based escrow marketplace to connect clients with verified workers for any job.';
|
||||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||||
?>
|
?>
|
||||||
<?php if ($projectDescription): ?>
|
<meta name="description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||||
<!-- Meta description -->
|
<meta property="og:title" content="SkillRunner - Find & Hire Verified Experts" />
|
||||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
|
||||||
<!-- Open Graph meta tags -->
|
|
||||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||||
<!-- Twitter meta tags -->
|
<meta property="twitter:card" content="summary_large_image">
|
||||||
|
<meta property="twitter:title" content="SkillRunner - Find & Hire Verified Experts" />
|
||||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||||
<?php endif; ?>
|
|
||||||
<?php if ($projectImageUrl): ?>
|
<?php if ($projectImageUrl): ?>
|
||||||
<!-- Open Graph image -->
|
|
||||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||||
<!-- Twitter image -->
|
|
||||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
<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>
|
</head>
|
||||||
<body>
|
<body class="bg-light">
|
||||||
<main>
|
<?php session_start(); ?>
|
||||||
<div class="card">
|
<nav class="navbar navbar-expand-lg navbar-light bg-white sticky-top">
|
||||||
<h1>Analyzing your requirements and generating your website…</h1>
|
<div class="container">
|
||||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
<a class="navbar-brand" href="/">SkillRunner</a>
|
||||||
<span class="sr-only">Loading…</span>
|
<div class="d-flex">
|
||||||
|
<?php if (isset($_SESSION['client_id'])): ?>
|
||||||
|
<a href="dashboard-client.php" class="btn btn-outline-primary me-2">Client Dashboard</a>
|
||||||
|
<a href="logout.php" class="btn btn-primary">Logout</a>
|
||||||
|
<?php elseif (isset($_SESSION['worker_id'])): ?>
|
||||||
|
<a href="dashboard.php" class="btn btn-outline-primary me-2">Dashboard</a>
|
||||||
|
<a href="logout.php" class="btn btn-primary">Logout</a>
|
||||||
|
<?php else: ?>
|
||||||
|
<a href="login.php" class="btn btn-outline-primary me-2">Worker Login</a>
|
||||||
|
<a href="register.php" class="btn btn-primary">Register</a>
|
||||||
|
<a href="login-client.php" class="btn btn-outline-secondary ms-2">Client Login</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
<a href="post-job.php" class="btn btn-secondary ms-2">Post a Job</a>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</main>
|
</nav>
|
||||||
<footer>
|
|
||||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
<header class="py-5">
|
||||||
|
<div class="container px-5 text-center">
|
||||||
|
<h1 class="display-3 fw-bolder mb-3">Get any job done, securely.</h1>
|
||||||
|
<p class="lead fw-normal text-muted mb-4">Post a task, fund the escrow with confidence, and release payment only when you're satisfied. <br> Powered by a community of verified, skilled professionals.</p>
|
||||||
|
<div class="d-grid gap-3 d-sm-flex justify-content-sm-center">
|
||||||
|
<a class="btn btn-primary btn-lg px-4 gap-3" href="post-job.php" role="button">Post a Job</a>
|
||||||
|
<a class="btn btn-outline-secondary btn-lg px-4" href="jobs.php" role="button">Find Work</a>
|
||||||
|
<a class="btn btn-outline-dark btn-lg px-4" href="#">Become a Worker</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<section class="py-5">
|
||||||
|
<div class="container px-5">
|
||||||
|
<div class="row gx-5">
|
||||||
|
<div class="col-lg-4 col-md-6 mb-5">
|
||||||
|
<div class="d-flex align-items-center mb-3">
|
||||||
|
<div class="feature bg-primary bg-gradient text-white rounded-3 me-3"><i class="bi bi-shield-check"></i></div>
|
||||||
|
<h2 class="h5 mb-0">Verified Experts</h2>
|
||||||
|
</div>
|
||||||
|
<p class="text-muted">Our workers undergo a verification process, so you hire with peace of mind.</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4 col-md-6 mb-5">
|
||||||
|
<div class="d-flex align-items-center mb-3">
|
||||||
|
<div class="feature bg-primary bg-gradient text-white rounded-3 me-3"><i class="bi bi-lock"></i></div>
|
||||||
|
<h2 class="h5 mb-0">Secure Escrow</h2>
|
||||||
|
</div>
|
||||||
|
<p class="text-muted">Your funds are held safely in escrow and are only released upon your approval.</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4 col-md-6 mb-5">
|
||||||
|
<div class="d-flex align-items-center mb-3">
|
||||||
|
<div class="feature bg-primary bg-gradient text-white rounded-3 me-3"><i class="bi bi-chat-dots"></i></div>
|
||||||
|
<h2 class="h5 mb-0">Dispute Resolution</h2>
|
||||||
|
</div>
|
||||||
|
<p class="text-muted">Admins are available to mediate and resolve any disputes that may arise.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<footer class="text-center py-4 text-muted border-top mt-5">
|
||||||
|
© <?php echo date("Y"); ?> SkillRunner. All Rights Reserved. | PHP Version: <?php echo phpversion(); ?>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
<style>
|
||||||
|
.feature {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 3rem;
|
||||||
|
width: 3rem;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
153
job-detail.php
Normal file
153
job-detail.php
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$job_id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
||||||
|
|
||||||
|
if ($job_id === 0) {
|
||||||
|
header("Location: jobs.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM jobs WHERE id = :id");
|
||||||
|
$stmt->bindParam(':id', $job_id, PDO::PARAM_INT);
|
||||||
|
$stmt->execute();
|
||||||
|
$job = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if (!$job) {
|
||||||
|
// Or show a "Job not found" message
|
||||||
|
header("Location: jobs.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
// In a real app, log this error instead of displaying it
|
||||||
|
die("Database error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title><?php echo htmlspecialchars($job['title']); ?> - SkillRunner</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<?php session_start(); ?>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="/">SkillRunner</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">
|
||||||
|
<?php if (isset($_SESSION['client_id'])): ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="dashboard-client.php">Client Dashboard</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="logout.php">Logout</a>
|
||||||
|
</li>
|
||||||
|
<?php elseif (isset($_SESSION['worker_id'])): ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="dashboard.php">Dashboard</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="logout.php">Logout</a>
|
||||||
|
</li>
|
||||||
|
<?php else: ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="login.php">Worker Login</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="register.php">Register</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="login-client.php">Client Login</a>
|
||||||
|
</li>
|
||||||
|
<?php endif; ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="btn btn-primary" href="post-job.php">Post a Job</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container mt-5">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-8 mx-auto">
|
||||||
|
|
||||||
|
<?php if (isset($_GET['application_status'])): ?>
|
||||||
|
<div class="alert <?php echo $_GET['application_status'] === 'success' ? 'alert-success' : 'alert-danger'; ?> alert-dismissible fade show" role="alert">
|
||||||
|
<?php if ($_GET['application_status'] === 'success'): ?>
|
||||||
|
Your application has been submitted successfully!
|
||||||
|
<?php else: ?>
|
||||||
|
There was an error submitting your application. You may have already applied for this job.
|
||||||
|
<?php endif; ?>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="card border-0 shadow-sm mb-4">
|
||||||
|
<div class="card-body p-4">
|
||||||
|
<h1 class="card-title h2 mb-3"><?php echo htmlspecialchars($job['title']); ?></h1>
|
||||||
|
<h6 class="card-subtitle mb-2 text-muted"><?php echo htmlspecialchars($job['category']); ?></h6>
|
||||||
|
<hr>
|
||||||
|
<p class="card-text fs-5"><?php echo nl2br(htmlspecialchars($job['description'])); ?></p>
|
||||||
|
|
||||||
|
<div class="my-4">
|
||||||
|
<h5 class="mb-3">Required Skills</h5>
|
||||||
|
<?php
|
||||||
|
$skills = explode(',', $job['skills']);
|
||||||
|
foreach ($skills as $skill): ?>
|
||||||
|
<span class="badge bg-secondary me-1 fs-6"><?php echo htmlspecialchars(trim($skill)); ?></span>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row text-center my-4 py-3 bg-light rounded">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<h5>Budget</h5>
|
||||||
|
<p class="fs-4 text-success">$<?php echo htmlspecialchars(number_format($job['budget'], 2)); ?></p>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<h5>Deadline</h5>
|
||||||
|
<p class="fs-4"><?php echo htmlspecialchars(date("F j, Y", strtotime($job['deadline']))); ?></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-grid">
|
||||||
|
<?php if (isset($_SESSION['worker_id'])): ?>
|
||||||
|
<form action="apply-for-job.php" method="POST">
|
||||||
|
<input type="hidden" name="job_id" value="<?php echo $job['id']; ?>">
|
||||||
|
<button type="submit" class="btn btn-primary btn-lg w-100">Apply for this Job</button>
|
||||||
|
</form>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="alert alert-info text-center">
|
||||||
|
Please <a href="login.php">login</a> or <a href="register.php">register</a> to apply for this job.
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="text-center mt-3">
|
||||||
|
<a href="jobs.php" class="text-secondary">← Back to all jobs</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="footer mt-auto py-3 bg-light text-center">
|
||||||
|
<div class="container">
|
||||||
|
<span class="text-muted">© <?php echo date("Y"); ?> SkillRunner. All rights reserved.</span>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
124
jobs.php
Normal file
124
jobs.php
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->query('SELECT title, category, budget, description, skills FROM jobs ORDER BY created_at DESC');
|
||||||
|
$jobs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
// In a real application, you would log this error and show a user-friendly message.
|
||||||
|
die("Could not connect to the database and fetch jobs: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Browse Jobs - SkillRunner</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||||
|
<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;500;600;700&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<?php session_start(); ?>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="/">SkillRunner</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">
|
||||||
|
<?php if (isset($_SESSION['client_id'])): ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="dashboard-client.php">Client Dashboard</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="logout.php">Logout</a>
|
||||||
|
</li>
|
||||||
|
<?php elseif (isset($_SESSION['worker_id'])): ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="dashboard.php">Dashboard</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="logout.php">Logout</a>
|
||||||
|
</li>
|
||||||
|
<?php else: ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="login.php">Worker Login</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="register.php">Register</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="login-client.php">Client Login</a>
|
||||||
|
</li>
|
||||||
|
<?php endif; ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="btn btn-primary" href="post-job.php">Post a Job</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container mt-5">
|
||||||
|
<div class="row mb-4">
|
||||||
|
<div class="col-12 text-center">
|
||||||
|
<h1 class="display-5 fw-bold">Open Opportunities</h1>
|
||||||
|
<p class="lead text-muted">Find your next project and start earning.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row g-4">
|
||||||
|
<?php if (empty($jobs)): ?>
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card text-center py-5">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">No Jobs Posted Yet</h5>
|
||||||
|
<p class="card-text">Check back soon for new opportunities or be the first to post a job!</p>
|
||||||
|
<a href="post-job.php" class="btn btn-primary">Post a Job</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php foreach ($jobs as $job): ?>
|
||||||
|
<div class="col-md-6 col-lg-4">
|
||||||
|
<div class="card h-100">
|
||||||
|
<div class="card-body d-flex flex-column">
|
||||||
|
<h5 class="card-title"><?php echo htmlspecialchars($job['title']); ?></h5>
|
||||||
|
<h6 class="card-subtitle mb-2 text-muted"><?php echo htmlspecialchars($job['category']); ?></h6>
|
||||||
|
<p class="card-text flex-grow-1"><?php echo htmlspecialchars(substr($job['description'], 0, 100)); ?>...</p>
|
||||||
|
<div>
|
||||||
|
<?php
|
||||||
|
$skills = explode(',', $job['skills']);
|
||||||
|
foreach ($skills as $skill) {
|
||||||
|
echo '<span class="badge bg-secondary me-1">' . htmlspecialchars(trim($skill)) . '</span>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex justify-content-between align-items-center mt-4">
|
||||||
|
<span class="text-success fw-bold fs-5">$<?php echo htmlspecialchars($job['budget']); ?></span>
|
||||||
|
<a href="job-detail.php?id=<?php echo $job['id']; ?>" class="btn btn-outline-primary">View Details</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="footer mt-auto py-3 bg-light">
|
||||||
|
<div class="container text-center">
|
||||||
|
<span class="text-muted">© <?php echo date("Y"); ?> SkillRunner. All rights reserved.</span>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
120
login-client.php
Normal file
120
login-client.php
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$email = $password = "";
|
||||||
|
$errors = [];
|
||||||
|
|
||||||
|
// If user is already logged in, redirect to dashboard
|
||||||
|
if (isset($_SESSION['client_id'])) {
|
||||||
|
header("Location: dashboard-client.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$email = trim($_POST['email']);
|
||||||
|
$password = $_POST['password'];
|
||||||
|
|
||||||
|
if (empty($email)) {
|
||||||
|
$errors[] = "Email is required.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($password)) {
|
||||||
|
$errors[] = "Password is required.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($errors)) {
|
||||||
|
$sql = "SELECT * FROM clients WHERE email = ?";
|
||||||
|
$stmt = db()->prepare($sql);
|
||||||
|
$stmt->execute([$email]);
|
||||||
|
$client = $stmt->fetch();
|
||||||
|
|
||||||
|
if ($client && password_verify($password, $client['password'])) {
|
||||||
|
$_SESSION['client_id'] = $client['id'];
|
||||||
|
$_SESSION['client_name'] = $client['name'];
|
||||||
|
header("Location: dashboard-client.php");
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$errors[] = "Invalid email or password.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Client Login - SkillRunner</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="index.php">SkillRunner</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="jobs.php">Find Work</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="post-job.php">Post a Job</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="login.php">Worker Login</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="btn btn-primary" href="register.php">Worker Register</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<main class="container mt-5">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h1 class="card-title text-center">Client Login</h1>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?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="login-client.php" method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Email Address</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($email); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="password" class="form-label">Password</label>
|
||||||
|
<input type="password" class="form-control" id="password" name="password" required>
|
||||||
|
</div>
|
||||||
|
<div class="d-grid">
|
||||||
|
<button type="submit" class="btn btn-primary">Login</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<p class="mt-3 text-center">Don't have a client account? <a href="register-client.php">Register here</a>.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="text-center mt-5 py-3 bg-light">
|
||||||
|
<p>© <?php echo date("Y"); ?> SkillRunner. All rights reserved.</p>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
123
login.php
Normal file
123
login.php
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$email = $password = "";
|
||||||
|
$errors = [];
|
||||||
|
|
||||||
|
// If user is already logged in, redirect to dashboard
|
||||||
|
if (isset($_SESSION['worker_id'])) {
|
||||||
|
header("Location: dashboard.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$email = trim($_POST['email']);
|
||||||
|
$password = $_POST['password'];
|
||||||
|
|
||||||
|
if (empty($email)) {
|
||||||
|
$errors[] = "Email is required.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($password)) {
|
||||||
|
$errors[] = "Password is required.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($errors)) {
|
||||||
|
$sql = "SELECT id, name, password FROM workers WHERE email = ?";
|
||||||
|
$stmt = db()->prepare($sql);
|
||||||
|
$stmt->execute([$email]);
|
||||||
|
$worker = $stmt->fetch();
|
||||||
|
|
||||||
|
if ($worker && password_verify($password, $worker['password'])) {
|
||||||
|
session_regenerate_id();
|
||||||
|
$_SESSION['worker_id'] = $worker['id'];
|
||||||
|
$_SESSION['worker_name'] = $worker['name'];
|
||||||
|
header("Location: dashboard.php");
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$errors[] = "Invalid email or password.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Worker Login - SkillRunner</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="index.php">SkillRunner</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="jobs.php">Find Work</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="post-job.php">Post a Job</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="login.php">Login</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="btn btn-primary" href="register.php">Register</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<main class="container mt-5">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-5">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h1 class="card-title text-center">Worker Login</h1>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?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="login.php" method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Email Address</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($email); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="password" class="form-label">Password</label>
|
||||||
|
<input type="password" class="form-control" id="password" name="password" required>
|
||||||
|
</div>
|
||||||
|
<div class="d-grid">
|
||||||
|
<button type="submit" class="btn btn-primary">Login</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer text-center">
|
||||||
|
<p>Don't have an account? <a href="register.php">Register here</a>.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="text-center mt-5 py-3 bg-light">
|
||||||
|
<p>© <?php echo date("Y"); ?> SkillRunner. All rights reserved.</p>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
16
logout.php
Normal file
16
logout.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
$_SESSION = [];
|
||||||
|
|
||||||
|
if (ini_get("session.use_cookies")) {
|
||||||
|
$params = session_get_cookie_params();
|
||||||
|
setcookie(session_name(), '', time() - 42000,
|
||||||
|
$params["path"], $params["domain"],
|
||||||
|
$params["secure"], $params["httponly"]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
session_destroy();
|
||||||
|
|
||||||
|
header("Location: index.php");
|
||||||
|
exit;
|
||||||
142
post-job.php
Normal file
142
post-job.php
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Post a New Job - SkillRunner</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
// Redirect to login if client is not logged in
|
||||||
|
if (!isset($_SESSION['client_id'])) {
|
||||||
|
header('Location: login-client.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-white sticky-top">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="/">SkillRunner</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">
|
||||||
|
<?php if (isset($_SESSION['client_id'])): ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="dashboard-client.php">Dashboard</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="logout.php">Logout</a>
|
||||||
|
</li>
|
||||||
|
<?php elseif (isset($_SESSION['worker_id'])): ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="dashboard.php">Dashboard</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="logout.php">Logout</a>
|
||||||
|
</li>
|
||||||
|
<?php else: ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="login.php">Login</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="register.php">Register</a>
|
||||||
|
</li>
|
||||||
|
<?php endif; ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="btn btn-primary" href="post-job.php">Post a Job</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<main class="container my-5">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-8 col-lg-7">
|
||||||
|
<div class="text-center mb-5">
|
||||||
|
<h1 class="display-5 fw-bold">Post a New Job</h1>
|
||||||
|
<p class="lead text-muted">Fill out the details below to find the perfect skilled worker.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="confirmation-alert" class="alert alert-success d-none" role="alert">
|
||||||
|
<i class="bi bi-check-circle-fill"></i> Your job has been posted successfully! You can <a href="/">view it on the job board</a> or post another one.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="post-job-form" action="add_job.php" method="POST" class="needs-validation" novalidate>
|
||||||
|
<input type="hidden" name="client_id" value="<?php echo $_SESSION['client_id']; ?>">
|
||||||
|
<div class="card p-4 mb-4">
|
||||||
|
<h5 class="card-title mb-4">Job Details</h5>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="title" class="form-label">Job Title</label>
|
||||||
|
<input type="text" class="form-control" id="title" name="title" placeholder="e.g., Senior Web Developer" required>
|
||||||
|
<div class="invalid-feedback">Please provide a job title.</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="description" class="form-label">Description</label>
|
||||||
|
<textarea class="form-control" id="description" name="description" rows="5" placeholder="Describe the responsibilities, requirements, and what makes this a great opportunity." required></textarea>
|
||||||
|
<div class="invalid-feedback">Please provide a job description.</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="category" class="form-label">Category</label>
|
||||||
|
<select class="form-select" id="category" name="category" required>
|
||||||
|
<option value="" disabled selected>Select a category...</option>
|
||||||
|
<option value="Web Development">Web Development</option>
|
||||||
|
<option value="Mobile Development">Mobile Development</option>
|
||||||
|
<option value="Design">Design</option>
|
||||||
|
<option value="Writing">Writing</option>
|
||||||
|
<option value="Marketing">Marketing</option>
|
||||||
|
<option value="Other">Other</option>
|
||||||
|
</select>
|
||||||
|
<div class="invalid-feedback">Please select a category.</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="skills" class="form-label">Required Skills</label>
|
||||||
|
<input type="text" class="form-control" id="skills" name="skills" placeholder="e.g., PHP, React, Figma" required>
|
||||||
|
<div class="form-text">Enter skills separated by commas.</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card p-4">
|
||||||
|
<h5 class="card-title mb-4">Budget & Deadline</h5>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="budget" class="form-label">Budget ($)</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-text">$</span>
|
||||||
|
<input type="number" class="form-control" id="budget" name="budget" placeholder="e.g., 5000" min="1" required>
|
||||||
|
<div class="invalid-feedback">Please enter a valid budget.</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="deadline" class="form-label">Deadline</label>
|
||||||
|
<input type="date" class="form-control" id="deadline" name="deadline" required>
|
||||||
|
<div class="invalid-feedback">Please set a deadline.</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-grid gap-2 mt-4">
|
||||||
|
<button type="submit" class="btn btn-primary btn-lg">Post Job & Fund Escrow</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="text-center py-4 text-muted border-top">
|
||||||
|
© <?php echo date("Y"); ?> SkillRunner. All Rights Reserved.
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
141
register-client.php
Normal file
141
register-client.php
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$name = $email = $password = $password_confirm = "";
|
||||||
|
$errors = [];
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$name = trim($_POST['name']);
|
||||||
|
$email = trim($_POST['email']);
|
||||||
|
$password = $_POST['password'];
|
||||||
|
$password_confirm = $_POST['password_confirm'];
|
||||||
|
|
||||||
|
if (empty($name)) {
|
||||||
|
$errors[] = "Name is required.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($email)) {
|
||||||
|
$errors[] = "Email is required.";
|
||||||
|
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$errors[] = "Invalid email format.";
|
||||||
|
} else {
|
||||||
|
$sql = "SELECT id FROM clients WHERE email = ?";
|
||||||
|
$stmt = db()->prepare($sql);
|
||||||
|
$stmt->execute([$email]);
|
||||||
|
if ($stmt->fetch()) {
|
||||||
|
$errors[] = "Email is already registered.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($password)) {
|
||||||
|
$errors[] = "Password is required.";
|
||||||
|
} elseif (strlen($password) < 8) {
|
||||||
|
$errors[] = "Password must be at least 8 characters long.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($password !== $password_confirm) {
|
||||||
|
$errors[] = "Passwords do not match.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($errors)) {
|
||||||
|
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
|
||||||
|
$sql = "INSERT INTO clients (name, email, password) VALUES (?, ?, ?)";
|
||||||
|
$stmt = db()->prepare($sql);
|
||||||
|
if ($stmt->execute([$name, $email, $hashed_password])) {
|
||||||
|
// $_SESSION['client_id'] = db()->lastInsertId();
|
||||||
|
// $_SESSION['client_name'] = $name;
|
||||||
|
header("Location: login-client.php");
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$errors[] = "Something went wrong. Please try again later.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Client Registration - SkillRunner</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="index.php">SkillRunner</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="jobs.php">Find Work</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="post-job.php">Post a Job</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="login.php">Worker Login</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="btn btn-primary" href="register.php">Worker Register</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<main class="container mt-5">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h1 class="card-title text-center">Create Your Client Account</h1>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?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-client.php" method="post" id="registration-form">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="name" class="form-label">Company Name</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($name); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Email Address</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($email); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="password" class="form-label">Password</label>
|
||||||
|
<input type="password" class="form-control" id="password" name="password" required>
|
||||||
|
<div class="form-text">Must be at least 8 characters long.</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="password_confirm" class="form-label">Confirm Password</label>
|
||||||
|
<input type="password" class="form-control" id="password_confirm" name="password_confirm" required>
|
||||||
|
</div>
|
||||||
|
<div class="d-grid">
|
||||||
|
<button type="submit" class="btn btn-primary">Register</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="text-center mt-5 py-3 bg-light">
|
||||||
|
<p>© <?php echo date("Y"); ?> SkillRunner. All rights reserved.</p>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
141
register.php
Normal file
141
register.php
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$name = $email = $password = $password_confirm = "";
|
||||||
|
$errors = [];
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$name = trim($_POST['name']);
|
||||||
|
$email = trim($_POST['email']);
|
||||||
|
$password = $_POST['password'];
|
||||||
|
$password_confirm = $_POST['password_confirm'];
|
||||||
|
|
||||||
|
if (empty($name)) {
|
||||||
|
$errors[] = "Name is required.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($email)) {
|
||||||
|
$errors[] = "Email is required.";
|
||||||
|
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$errors[] = "Invalid email format.";
|
||||||
|
} else {
|
||||||
|
$sql = "SELECT id FROM workers WHERE email = ?";
|
||||||
|
$stmt = db()->prepare($sql);
|
||||||
|
$stmt->execute([$email]);
|
||||||
|
if ($stmt->fetch()) {
|
||||||
|
$errors[] = "Email is already registered.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($password)) {
|
||||||
|
$errors[] = "Password is required.";
|
||||||
|
} elseif (strlen($password) < 8) {
|
||||||
|
$errors[] = "Password must be at least 8 characters long.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($password !== $password_confirm) {
|
||||||
|
$errors[] = "Passwords do not match.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($errors)) {
|
||||||
|
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
|
||||||
|
$sql = "INSERT INTO workers (name, email, password) VALUES (?, ?, ?)";
|
||||||
|
$stmt = db()->prepare($sql);
|
||||||
|
if ($stmt->execute([$name, $email, $hashed_password])) {
|
||||||
|
// $_SESSION['worker_id'] = db()->lastInsertId();
|
||||||
|
// $_SESSION['worker_name'] = $name;
|
||||||
|
header("Location: login.php");
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$errors[] = "Something went wrong. Please try again later.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Worker Registration - SkillRunner</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="index.php">SkillRunner</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="jobs.php">Find Work</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="post-job.php">Post a Job</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="login.php">Login</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="btn btn-primary" href="register.php">Register</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<main class="container mt-5">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h1 class="card-title text-center">Create Your Worker Account</h1>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?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" id="registration-form">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="name" class="form-label">Full Name</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($name); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Email Address</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($email); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="password" class="form-label">Password</label>
|
||||||
|
<input type="password" class="form-control" id="password" name="password" required>
|
||||||
|
<div class="form-text">Must be at least 8 characters long.</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="password_confirm" class="form-label">Confirm Password</label>
|
||||||
|
<input type="password" class="form-control" id="password_confirm" name="password_confirm" required>
|
||||||
|
</div>
|
||||||
|
<div class="d-grid">
|
||||||
|
<button type="submit" class="btn btn-primary">Register</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="text-center mt-5 py-3 bg-light">
|
||||||
|
<p>© <?php echo date("Y"); ?> SkillRunner. All rights reserved.</p>
|
||||||
|
</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