= htmlspecialchars($job['job_title']) ?>
Job Description
= nl2br(htmlspecialchars($job['job_description'])) ?>
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'); $is_employer = ($_SESSION['user_type'] === 'Employer'); // 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."; } } // Handle job deletion (for employers only) if (isset($_POST['remove']) && $is_employer) { $conn->begin_transaction(); // Start a transaction try { // Delete related applications $sql_delete_applications = "DELETE FROM applications WHERE job_id = ?"; $stmt_delete_applications = $conn->prepare($sql_delete_applications); $stmt_delete_applications->bind_param("i", $job_id); $stmt_delete_applications->execute(); // Delete the job posting $sql_delete_job = "DELETE FROM job_postings WHERE job_id = ?"; $stmt_delete_job = $conn->prepare($sql_delete_job); $stmt_delete_job->bind_param("i", $job_id); $stmt_delete_job->execute(); $conn->commit(); // Commit the transaction echo ''; exit(); } catch (Exception $e) { $conn->rollback(); // Rollback the transaction on error $delete_message = "There was an error while deleting the job. Please try again later."; } } ?>
= nl2br(htmlspecialchars($job['job_description'])) ?>