-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_subject.php
More file actions
35 lines (34 loc) · 902 Bytes
/
delete_subject.php
File metadata and controls
35 lines (34 loc) · 902 Bytes
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
<?php require_once("includes/sessions.php"); ?>
<?php
if (!isset($_SESSION['username'])) {
header("Location: index.php");
exit;
}
?>
<?php require_once("includes/dbconnection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php
if (intval($_GET['subj']) == 0) {
//redirect
redirect_to("content.php");
}
$id = mysql_prep($_GET['subj']);
if ($subject = get_subject_by_id($id)) {
$query = "DELETE FROM subjects WHERE id = '$id' LIMIT 1";
$result = mysql_query($query, $dbconnect);
if (mysql_affected_rows() == 1) {
redirect_to("content.php?q=subjectdeleted");
} else {
//DELETION FAILED
echo "<p>Subject deletion failed.</p>";
echo "<p>" . mysql_error() . "</p>";
echo "<a href=\"content.php\">Return to Main Page</a>";
}
} else {
//SUBJECT DIDN"T EXIST
redirect_to("content.php");
}
?>
<?php
mysql_close($dbconnect);
?>