59 lines
2.0 KiB
PHP
59 lines
2.0 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header("Location: login.php");
|
|
exit();
|
|
}
|
|
|
|
$userId = $_SESSION['user_id'];
|
|
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare(
|
|
'SELECT t.title, t.description, a.status, u.username AS poster_username
|
|
FROM applications a
|
|
JOIN tasks t ON a.task_id = t.id
|
|
JOIN users u ON t.user_id = u.id
|
|
WHERE a.user_id = :user_id
|
|
ORDER BY a.created_at DESC'
|
|
);
|
|
$stmt->bindParam(':user_id', $userId, PDO::PARAM_INT);
|
|
$stmt->execute();
|
|
$applications = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
} catch (PDOException $e) {
|
|
// In a real application, you would log this error
|
|
die("Database error: Could not retrieve your applications.");
|
|
}
|
|
|
|
$pageTitle = "My Applications";
|
|
include 'shared/header.php';
|
|
?>
|
|
|
|
<div class="container">
|
|
<div class="page-header">
|
|
<h1>My Applications</h1>
|
|
<p>Here are the tasks you've applied for and their current status.</p>
|
|
</div>
|
|
|
|
<?php if (empty($applications)): ?>
|
|
<div class="alert alert-info">You have not applied for any tasks yet.</div>
|
|
<?php else: ?>
|
|
<div class="applications-list">
|
|
<?php foreach ($applications as $app): ?>
|
|
<div class="application-card">
|
|
<h2><?php echo htmlspecialchars($app['title']); ?></h2>
|
|
<p class="task-poster">Posted by: <strong><?php echo htmlspecialchars($app['poster_username']); ?></strong></p>
|
|
<p><?php echo nl2br(htmlspecialchars($app['description'])); ?></p>
|
|
<div class="application-status">
|
|
Status: <span class="status-badge status-<?php echo strtolower(htmlspecialchars($app['status'])); ?>"><?php echo htmlspecialchars($app['status']); ?></span>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php include 'shared/footer.php'; ?>
|