43 lines
1.5 KiB
PHP
43 lines
1.5 KiB
PHP
<?php
|
|
require_once 'includes/header.php';
|
|
require_once 'db/config.php';
|
|
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header('Location: login.php');
|
|
exit();
|
|
}
|
|
|
|
$user_id = $_SESSION['user_id'];
|
|
|
|
$p = db()->prepare('SELECT s.name, s.description FROM services s JOIN user_services us ON s.id = us.service_id WHERE us.user_id = ?');
|
|
$p->execute([$user_id]);
|
|
$services = $p->fetchAll();
|
|
|
|
?>
|
|
|
|
<div class="container">
|
|
<h1 class="mt-5">Dashboard</h1>
|
|
<p class="lead">Welcome to your dashboard. Here are the services you are subscribed to:</p>
|
|
|
|
<div class="row">
|
|
<?php if (empty($services)): ?>
|
|
<div class="col-12">
|
|
<p>You are not subscribed to any services yet.</p>
|
|
</div>
|
|
<?php else: ?>
|
|
<?php foreach ($services as $service): ?>
|
|
<div class="col-md-4">
|
|
<div class="card mb-4">
|
|
<div class="card-body">
|
|
<h5 class="card-title"><?php echo htmlspecialchars($service['name']); ?></h5>
|
|
<p class="card-text"><?php echo htmlspecialchars($service['description']); ?></p>
|
|
<a href="services/<?php echo strtolower(str_replace(' ', '', $service['name'])); ?>.php" class="btn btn-primary">Go to service</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php require_once 'includes/footer.php'; ?>
|