You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
YOLO/job_details.php

121 lines
4.0 KiB

<?php
session_start();
// Check if the user is logged in
if (!isset($_SESSION['email'])) {
header("Location: login.php");
exit();
}
$seeker_id = $_SESSION['seeker_id'];
include 'connect.php';
// Get job ID from URL
$job_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if ($job_id > 0) {
// Query to get job details by job_id
$sql = "SELECT * FROM job_postings WHERE job_id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $job_id);
$stmt->execute();
$result = $stmt->get_result();
// Check if the job exists
if ($result->num_rows > 0) {
$job = $result->fetch_assoc();
} else {
echo "Job not found.";
exit();
}
} else {
echo "Invalid job ID.";
exit();
}
// Check if the logged-in user is a job seeker
$is_job_seeker = ($_SESSION['user_type'] === 'Job seeker');
// Handle job application
if (isset($_POST['apply']) && $is_job_seeker) {
// Get seeker_id from session
$seeker_id = $_SESSION['seeker_id'];
$application_date = date('Y-m-d H:i:s'); // Current date and time
$status = 'Pending'; // Default status
// Insert the application into the applications table
$sql_apply = "INSERT INTO applications (job_id, seeker_id, application_date, status) VALUES (?, ?, ?, ?)";
$stmt_apply = $conn->prepare($sql_apply);
$stmt_apply->bind_param("iiss", $job_id, $seeker_id, $application_date, $status);
if ($stmt_apply->execute()) {
$application_message = "You have successfully applied for this job!";
} else {
$application_message = "There was an error while applying. Please try again later.";
}
}
?>
<!DOCTYPE html>
<html lang="en" data-theme="light">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Job Details</title>
<link href="https://cdn.jsdelivr.net/npm/daisyui@4.7.2/dist/full.min.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="min-h-screen bg-base-200">
<?php include 'navbar.php'; ?>
<main class="container mx-auto px-4 py-8">
<!-- Breadcrumb -->
<div class="text-sm breadcrumbs mb-6">
<ul>
<li><a href="index.php">Home</a></li>
<li class="text-primary">Job Details</li>
</ul>
</div>
<div class="max-w-4xl mx-auto bg-base-100 shadow-xl p-6">
<h2 class="text-3xl font-bold mb-4"><?= htmlspecialchars($job['job_title']) ?></h2>
<p class="text-lg font-medium mb-2"><strong>Location:</strong> <?= htmlspecialchars($job['location']) ?></p>
<p class="text-lg font-medium mb-2"><strong>Salary:</strong> <?= htmlspecialchars($job['salary']) ?></p>
<p class="text-lg font-medium mb-2"><strong>Posted Date:</strong> <?= date('F j, Y', strtotime($job['posted_date'])) ?></p>
<div class="mt-4">
<h3 class="text-2xl font-semibold mb-3">Job Description</h3>
<p><?= nl2br(htmlspecialchars($job['job_description'])) ?></p>
</div>
<!-- Display Application Message -->
<?php if (isset($application_message)): ?>
<div class="mt-4 text-center text-lg font-medium">
<?= htmlspecialchars($application_message) ?>
</div>
<?php endif; ?>
<!-- Apply Button for Job Seekers -->
<?php if ($is_job_seeker): ?>
<form method="POST">
<div class="mt-6">
<button type="submit" name="apply" class="btn btn-primary btn-block">Apply for Job</button>
</div>
</form>
<?php else: ?>
<div class="mt-6">
<button class="btn btn-disabled btn-block" disabled>You must be a job seeker to apply</button>
</div>
<?php endif; ?>
</div>
</main>
<?php include 'footer.php'; ?>
</body>
</html>
<?php
$conn->close();
?>