-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete-course.php
More file actions
40 lines (30 loc) · 1.1 KB
/
delete-course.php
File metadata and controls
40 lines (30 loc) · 1.1 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
<?php include 'layout/header.php';?>
<?php require_once("includes/db_connection.php"); ?>
<?php
if (isset($_GET['course_id'])) {
$course_id = $_GET["course_id"]; //Refactor this validation later
}
else{
$course_id = NULL;
}
if ($course_id == NULL) {
redirect_to("view-courses.php");
}
$course_deleted = 1;
$query = "UPDATE courses SET course_deleted = '{$course_deleted}' WHERE course_id = {$course_id} LIMIT 1";
$result = mysqli_query($connection, $query);
//close database connection after an sql command
if ($result === TRUE) {
echo "<script type='text/javascript'>";
echo "alert('Course set to inactive!');";
echo "</script>";
$URL="view-courses.php";
echo "<script>location.href='$URL'</script>";
} else {
echo "Error updating record: " . $connection->error;
}
//removed the redirect function and replaced it with javascript alert above
//still need to use the redirect function in case javascript is turned off
//redirect_to("new-subject.php");
if(isset($connection)){ mysqli_close($connection); }
?>