-
Notifications
You must be signed in to change notification settings - Fork 0
/
drop_course_result.php
51 lines (41 loc) · 1.63 KB
/
drop_course_result.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
41
42
43
44
45
46
47
48
49
50
51
<html>
<head>
<title>University Registration</title>
</head>
<body style="background-color: LavenderBlush ; color: Indigo ;">
<h1> Drop a Course </h1>
<?php
session_start();
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "university";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
else if (isset($_SESSION['user_id'])) {
// Delete the record
$sql = "DELETE FROM takes_course WHERE courseID = " . $_POST['course'];
if ($conn->query($sql) === TRUE) {
echo "Course was dropped successfully <br />";
} else {
echo "Error deleting record: " . $conn->error;
}
$sql = "UPDATE courses SET numberOfStudents = numberOfStudents - 1 WHERE ID =" . "'" . $_POST['course'] . "'";
echo "<br>Click <a href = 'dashboard.php'> here </a> to return to dashboard. <br />";
}
else{
?>
<br>
You're not even logged in! Click <a href = "dashboard.php"> here </a> to return to dashboard. <br />
<br>
<?php
}
$conn->close();
?>
<h6> University Registration </h6>
</body>
</html>