diff --git a/code/view_students.php b/code/view_students.php new file mode 100644 index 0000000000000000000000000000000000000000..1317a62bed1fd0c28358903e61e8bdb65908bb4e --- /dev/null +++ b/code/view_students.php @@ -0,0 +1,72 @@ +<?php +include 'config.php'; +session_start(); + +if (!isset($_SESSION['user']) || $_SESSION['user']['role'] !== 'tutor') { + header('Location: login.php'); + exit; +} + +$user = $_SESSION['user']; + +// Récupérer les informations des sessions et des étudiants +$students = []; +$stmt = $conn->prepare(" + SELECT s.subject AS session_subject, s.created_at AS session_date, + u.first_name, u.last_name, u.email + FROM SessionStudent ss + JOIN Session s ON ss.session_id = s.id + JOIN User u ON ss.student_id = u.id + WHERE s.tutor_id = ? +"); +$stmt->bind_param("i", $user['id']); +$stmt->execute(); +$result = $stmt->get_result(); +while ($row = $result->fetch_assoc()) { + $students[] = $row; +} +$stmt->close(); +?> +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Students in Your Sessions</title> + <link rel="stylesheet" href="style.css"> +</head> +<body> + <?php include 'sidebar.php'; ?> + + <div class="main-content"> + <div class="students-sessions-page"> + <h1>Students in Your Sessions</h1> + <?php if (!empty($students)): ?> + <table border="1" cellpadding="10" cellspacing="0"> + <thead> + <tr> + <th>Subject</th> + <th>Session Date</th> + <th>Student Name</th> + <th>Student Email</th> + </tr> + </thead> + <tbody> + <?php foreach ($students as $student): ?> + <tr> + <td><?= htmlspecialchars($student['session_subject']) ?></td> + <td><?= htmlspecialchars($student['session_date']) ?></td> + <td><?= htmlspecialchars($student['first_name']) . ' ' . htmlspecialchars($student['last_name']) ?></td> + <td><a href="mailto:<?= htmlspecialchars($student['email']) ?>"><?= htmlspecialchars($student['email']) ?></a></td> + </tr> + <?php endforeach; ?> + </tbody> + </table> + <?php else: ?> + <p>No students are enrolled in your sessions yet.</p> + <?php endif; ?> + <br> + </div> + </div> +</body> +</html>