-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_committe_member.php
More file actions
57 lines (50 loc) · 1.41 KB
/
delete_committe_member.php
File metadata and controls
57 lines (50 loc) · 1.41 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
47
48
49
50
51
52
53
54
55
56
57
<?php
session_start();
if (!isset($_SESSION["FacultyID"]) || !$_SESSION["isDepartmentAdmin"]) {
header("Location: login.php");
exit();
}
require 'server_config.php';
require 'upload.php';
require './services/committe_member.service.php';
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if (isset($_GET['ID'])) {
$ID = $_GET['ID'];
// Use prepared statements to prevent SQL injection
$stmt = $conn->prepare("SELECT * FROM committe_member WHERE CommitteId = ?");
$stmt->bind_param("i", $ID);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$committe = new CommittememberService();
$deleteResult = $committe->delete($ID);
if ($deleteResult) {
$_SESSION['notification'] = array(
"message" => "Record deleted successfully",
"type" => "success",
);
header("Location: committe_member.php");
exit();
} else {
$_SESSION['notification'] = array(
"message" => "Error deleting record",
"type" => "danger",
);
header("Location: committe_member.php");
exit();
}
} else {
$_SESSION['notification'] = array(
"message" => "No record found",
"type" => "danger",
);
header("Location: committe_member.php");
exit();
}
} else {
echo "ID parameter is missing";
}
$conn->close();
?>