diff --git a/admin/add_course.php b/admin/add_course.php
new file mode 100644
index 0000000..8065cd2
--- /dev/null
+++ b/admin/add_course.php
@@ -0,0 +1,41 @@
+prepare("INSERT INTO courses (name, description) VALUES (?, ?)");
+ $stmt->execute([$name, $description]);
+
+ header("Location: courses.php");
+ exit;
+}
+
+require_once 'partials/header.php';
+?>
+
+
+
+
diff --git a/admin/add_student.php b/admin/add_student.php
new file mode 100644
index 0000000..d5461d1
--- /dev/null
+++ b/admin/add_student.php
@@ -0,0 +1,41 @@
+prepare("INSERT INTO students (username, password) VALUES (?, ?)");
+ $stmt->execute([$username, $password]);
+
+ header("Location: students.php");
+ exit;
+}
+
+require_once 'partials/header.php';
+?>
+
+
+
+
diff --git a/admin/courses.php b/admin/courses.php
new file mode 100644
index 0000000..7b12fa0
--- /dev/null
+++ b/admin/courses.php
@@ -0,0 +1,46 @@
+query("SELECT * FROM courses");
+$courses = $stmt->fetchAll();
+
+?>
+
+
+
Manage Courses
+
Add Course
+
+
+
+ | ID |
+ Name |
+ Description |
+ Actions |
+
+
+
+
+
+ |
+ |
+ |
+
+ Edit
+ Delete
+ |
+
+
+
+
+
+
+
diff --git a/admin/delete_course.php b/admin/delete_course.php
new file mode 100644
index 0000000..141bfa3
--- /dev/null
+++ b/admin/delete_course.php
@@ -0,0 +1,33 @@
+prepare("SELECT id FROM enrollments WHERE course_id = ?");
+$stmt->execute([$course_id]);
+$enrollments = $stmt->fetchAll();
+
+foreach ($enrollments as $enrollment) {
+ $stmt = $pdo->prepare("DELETE FROM grades WHERE enrollment_id = ?");
+ $stmt->execute([$enrollment['id']]);
+}
+
+$stmt = $pdo->prepare("DELETE FROM enrollments WHERE course_id = ?");
+$stmt->execute([$course_id]);
+
+// Now, delete the course
+$stmt = $pdo->prepare("DELETE FROM courses WHERE id = ?");
+$stmt->execute([$course_id]);
+
+header("Location: courses.php");
+exit;
diff --git a/admin/delete_student.php b/admin/delete_student.php
new file mode 100644
index 0000000..3a10585
--- /dev/null
+++ b/admin/delete_student.php
@@ -0,0 +1,33 @@
+prepare("SELECT id FROM enrollments WHERE student_id = ?");
+$stmt->execute([$student_id]);
+$enrollments = $stmt->fetchAll();
+
+foreach ($enrollments as $enrollment) {
+ $stmt = $pdo->prepare("DELETE FROM grades WHERE enrollment_id = ?");
+ $stmt->execute([$enrollment['id']]);
+}
+
+$stmt = $pdo->prepare("DELETE FROM enrollments WHERE student_id = ?");
+$stmt->execute([$student_id]);
+
+// Now, delete the student
+$stmt = $pdo->prepare("DELETE FROM students WHERE id = ?");
+$stmt->execute([$student_id]);
+
+header("Location: students.php");
+exit;
diff --git a/admin/edit_course.php b/admin/edit_course.php
new file mode 100644
index 0000000..edf5ec2
--- /dev/null
+++ b/admin/edit_course.php
@@ -0,0 +1,47 @@
+prepare("UPDATE courses SET name = ?, description = ? WHERE id = ?");
+ $stmt->execute([$name, $description, $course_id]);
+
+ header("Location: courses.php");
+ exit;
+}
+
+$stmt = $pdo->prepare("SELECT * FROM courses WHERE id = ?");
+$stmt->execute([$course_id]);
+$course = $stmt->fetch();
+
+require_once 'partials/header.php';
+?>
+
+
+
Edit Course
+
+
+
+
diff --git a/admin/edit_student.php b/admin/edit_student.php
new file mode 100644
index 0000000..43f2a3c
--- /dev/null
+++ b/admin/edit_student.php
@@ -0,0 +1,58 @@
+prepare($sql);
+ $stmt->execute($params);
+
+ header("Location: students.php");
+ exit;
+}
+
+$stmt = $pdo->prepare("SELECT * FROM students WHERE id = ?");
+$stmt->execute([$student_id]);
+$student = $stmt->fetch();
+
+require_once 'partials/header.php';
+?>
+
+
+
+
diff --git a/admin/enrollments.php b/admin/enrollments.php
new file mode 100644
index 0000000..1eca2e1
--- /dev/null
+++ b/admin/enrollments.php
@@ -0,0 +1,106 @@
+prepare("SELECT id FROM enrollments WHERE student_id = ? AND course_id = ?");
+ $stmt->execute([$student_id, $course_id]);
+ if (!$stmt->fetch()) {
+ $stmt = $pdo->prepare("INSERT INTO enrollments (student_id, course_id) VALUES (?, ?)");
+ $stmt->execute([$student_id, $course_id]);
+ }
+
+ header("Location: enrollments.php");
+ exit;
+}
+
+// Fetch all students and courses for dropdowns
+$students_stmt = $pdo->query("SELECT * FROM students");
+$students = $students_stmt->fetchAll();
+
+$courses_stmt = $pdo->query("SELECT * FROM courses");
+$courses = $courses_stmt->fetchAll();
+
+// Fetch all enrollments with student and course names
+$enrollments_stmt = $pdo->query("
+ SELECT e.id, s.username, c.name as course_name
+ FROM enrollments e
+ JOIN students s ON e.student_id = s.id
+ JOIN courses c ON e.course_id = c.id
+ ORDER BY s.username, c.name
+");
+$enrollments = $enrollments_stmt->fetchAll();
+
+require_once 'partials/header.php';
+?>
+
+
+
Manage Enrollments
+
+
+
+
+
+
+
+
+
Current Enrollments
+
+
+
+ | Student |
+ Course |
+ Actions |
+
+
+
+
+
+ |
+ |
+
+ Unenroll
+ |
+
+
+
+
+
+
+
diff --git a/admin/grades.php b/admin/grades.php
new file mode 100644
index 0000000..22aba2d
--- /dev/null
+++ b/admin/grades.php
@@ -0,0 +1,84 @@
+prepare("SELECT id FROM grades WHERE enrollment_id = ?");
+ $stmt->execute([$enrollment_id]);
+ $existing_grade = $stmt->fetch();
+
+ if ($existing_grade) {
+ // Update existing grade
+ $stmt = $pdo->prepare("UPDATE grades SET grade = ? WHERE id = ?");
+ $stmt->execute([$grade, $existing_grade['id']]);
+ } else {
+ // Insert new grade
+ $stmt = $pdo->prepare("INSERT INTO grades (enrollment_id, grade) VALUES (?, ?)");
+ $stmt->execute([$enrollment_id, $grade]);
+ }
+
+ header("Location: grades.php");
+ exit;
+}
+
+
+// Fetch all enrollments with student, course, and grade information
+$enrollments_stmt = $pdo->query("
+ SELECT e.id, s.username, c.name as course_name, g.grade
+ FROM enrollments e
+ JOIN students s ON e.student_id = s.id
+ JOIN courses c ON e.course_id = c.id
+ LEFT JOIN grades g ON e.id = g.enrollment_id
+ ORDER BY s.username, c.name
+");
+$enrollments = $enrollments_stmt->fetchAll();
+
+require_once 'partials/header.php';
+?>
+
+
+
+
diff --git a/admin/index.php b/admin/index.php
new file mode 100644
index 0000000..494a1c1
--- /dev/null
+++ b/admin/index.php
@@ -0,0 +1,18 @@
+
+
+
+
Admin Dashboard
+
Welcome, !
+
This is the admin dashboard. From here you can manage students, courses, enrollments, and grades.
+
+
+
diff --git a/admin/login.php b/admin/login.php
new file mode 100644
index 0000000..e0ca5db
--- /dev/null
+++ b/admin/login.php
@@ -0,0 +1,64 @@
+prepare("SELECT * FROM admins WHERE username = ?");
+ $stmt->execute([$username]);
+ $admin = $stmt->fetch();
+
+ if ($admin && password_verify($password, $admin['password'])) {
+ $_SESSION['admin_logged_in'] = true;
+ $_SESSION['admin_id'] = $admin['id'];
+ $_SESSION['admin_username'] = $admin['username'];
+ header("Location: index.php");
+ exit;
+ } else {
+ $error = "Invalid credentials";
+ }
+}
+?>
+
+
+
+
+
+
+ Admin Login
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/admin/logout.php b/admin/logout.php
new file mode 100644
index 0000000..766a593
--- /dev/null
+++ b/admin/logout.php
@@ -0,0 +1,6 @@
+
+