Repository navigation
Expand file tree
/
Copy pathdeleteProject.php
More file actions
58 lines (49 loc) · 1.84 KB
/
Copy pathdeleteProject.php
File metadata and controls
58 lines (49 loc) · 1.84 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
58
<?php
require_once("included_functions.php");
require_once("session.php");
verify_login();
new_header("Projects", "");
$mysqli = db_connection();
if (($output = message()) !== null) {
echo $output;
}
//as long as a project has been selected
if (isset($_GET["project"]) && $_GET["project"] !== "") {
//project number
$num = $_GET["project"];
//host number associated with the given project
$host = $_GET["host"];
//must delete this projects information from approval table because of dependencies
$query2 = "DELETE FROM Approvals WHERE project = ".$num;
$result2 = $mysqli->query($query2);
//must delete team leader who is on this project -- later should change this to null if possible
$query3 = "DELETE FROM Team_Leaders WHERE tl_project = ".$num;
$result3 = $mysqli->query($query3);
//must set project number to null for volunteers who were supposed to be on the project to be deleted
$query4 = "update volunteers set project=NULL where project=".$num;
$result4 = $mysqli->query($query4);
//finally delete project
$query = "DELETE FROM Projects WHERE Project_Number = ".$num;
// Execute query
$result = $mysqli->query($query);
//////////////////////////////////////////////////////////////////////////////////////
if ($result && $result2 && $mysqli->affected_rows === 1) {
//if deleted redirect to the hosts registered projects
$_SESSION["message"] = "Project successfully deleted!";
redirect_to("viewHostProjects.php?id=".$host);
exit;
}
else {
//otherwise let user know you were unable to delete project
$_SESSION["message"] = "Could not delete project";
redirect_to("viewHostProjects.php?id=".$host);
exit;
}
}
else {
$_SESSION["message"] = "Project could not be found!";
redirect_to("viewHostProjects.php?id=".$host);
exit;
}
?>
<?php new_footer("Volunteers", $mysqli); ?>