-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_committe.php
More file actions
45 lines (41 loc) · 1.33 KB
/
delete_committe.php
File metadata and controls
45 lines (41 loc) · 1.33 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
<?php
session_start();
if (!isset($_SESSION["FacultyID"]) || !$_SESSION["isDepartmentAdmin"]) {
header("Location: login.php");
exit();
}
require 'server_config.php';
if (isset($_GET['CommitteId'])) {
$committeId = $_GET['CommitteId'];
// Check if the committee has members
$checkSql = "SELECT COUNT(*) as memberCount FROM committe_member WHERE CommitteID = ?";
$stmt = $conn->prepare($checkSql);
$stmt->bind_param("i", $committeId);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
$stmt->close();
if ($row['memberCount'] > 0) {
// Redirect back with an error message
$_SESSION['error'] = "Cannot delete committee with members.";
header("Location: committe.php");
exit();
} else {
// Proceed with deletion
$sql = "DELETE FROM committe WHERE CommitteId = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $committeId);
if ($stmt->execute()) {
$_SESSION['success'] = "Committee deleted successfully.";
} else {
$_SESSION['error'] = "Error deleting committee.";
}
$stmt->close();
header("Location: committe.php");
exit();
}
} else {
header("Location: committe.php");
exit();
}
?>