-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddCourse.php
40 lines (37 loc) · 1.14 KB
/
addCourse.php
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
<?php
session_start();
require 'DatabaseConnection.php';
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$db = new Database();
$studentId = $_SESSION['user_id'];
$courseId = $_POST['course_id'];
$semester = "Fall 2025";
$result = $db->registerCourse($studentId, $courseId, $semester);
if ($result) {
echo "Course registered successfully!";
} else {
echo "Failed to register course.";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Register for a Course</title>
</head>
<body>
<?php include 'header.php';?>
<h1>Register for a Course</h1>
<form action="addCourse.php" method="POST">
<label for="course_id">Course ID:</label>
<input type="text" name="course_id" required>
<button type="submit">Register</button>
</form>
<a href="dashboard.php">Back to Dashboard</a>
</body>
</html>