-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.php
More file actions
54 lines (46 loc) · 1.54 KB
/
project.php
File metadata and controls
54 lines (46 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
session_start();
require 'config/db.php';
if (!isset($_SESSION['user_id']) || !isset($_GET['id'])) {
header("Location: dashboard.php");
exit;
}
$project_id = $_GET['id'];
// Проверяем, есть ли проект
$stmt = $pdo->prepare("SELECT * FROM projects WHERE id = ? AND user_id = ?");
$stmt->execute([$project_id, $_SESSION['user_id']]);
$project = $stmt->fetch();
if (!$project) {
die("Проект не найден.");
}
// Получаем задачи
$stmt = $pdo->prepare("SELECT * FROM tasks WHERE project_id = ?");
$stmt->execute([$project_id]);
$tasks = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title><?php echo htmlspecialchars($project['name']); ?></title>
<link rel="stylesheet" href="assets/style.css">
</head>
<body>
<div class="container">
<h1><?php echo htmlspecialchars($project['name']); ?></h1>
<!-- Если нет задач, показываем кнопку -->
<?php if (empty($tasks)): ?>
<p>Задач пока нет.</p>
<a href="add_task.php?project_id=<?php echo $project_id; ?>" class="button">Добавить задачу</a>
<?php else: ?>
<h2>Список задач</h2>
<ul>
<?php foreach ($tasks as $task): ?>
<li><?php echo htmlspecialchars($task['title']); ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<a href="dashboard.php">Назад</a>
</div>
</body>
</html>