-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd_enrollment.php
More file actions
46 lines (38 loc) · 1.39 KB
/
add_enrollment.php
File metadata and controls
46 lines (38 loc) · 1.39 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
<html>
<head>
<title>Add Course</title>
</head>
<body>
<?php
//including the database connection file
include_once("config.php");
if(isset($_POST['Submit_Enrollment'])) {
//$id = mysqli_real_escape_string($mysqli, $_POST['id']);
//$department_name = mysqli_real_escape_string($con, $_POST['department_name']);
$course_id = mysqli_real_escape_string($con, $_POST['course_name']);
$user_id = mysqli_real_escape_string($con, $_POST['username']);
// checking empty fields
if(empty($course_id) || empty($user_id)) {
if(empty($course_id)) {
echo "<font color='red'>Add Course Name</font><br/>";
}
if(empty($user_id)) {
echo "<font color='red'>Enter User ID</font><br/>";
}
//link to the previous page
echo "<br/><a href='index.php'>Go Back</a>";
} else {
// if all the fields are filled (not empty)
//insert data to database
//$user_id = mysqli_real_escape_string($con, $_POST['username']);
//$course_id = mysqli_real_escape_string($con, $_POST['course_name']);
$insert_enrollment_table = mysqli_query($con, "INSERT INTO enrollment(user_id,course_id,enrollment_active) VALUES('$user_id', '$course_id','1')");
//echo $result;
//display success message
echo "<font color='green'>Data added successfully.";
echo "<br/><a href='index.php'>View Result</a>";
}
}
?>
</body>
</html>