-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
76 lines (69 loc) · 3.07 KB
/
delete.php
File metadata and controls
76 lines (69 loc) · 3.07 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
session_start();
include("conn.php");
$username = $_SESSION["username"];
if(isset($_SESSION['username'])){
if(!empty($_GET)){
if(isset($_GET['department']) && isset($_GET['id'])){
$si = $_SESSION['username'] . "_" . $_GET['department'] ."_students";
$sq = "DELETE FROM ".$si." where collegeid = '".$_GET['id']."'";
$sl = $_SESSION['username'] . "_" . $_GET['department'] . "_" . $_GET['id'];
$slq = "DROP Table IF EXISTS ".$sl;
mysqli_query($conn, $slq);
mysqli_query($conn, $sq);
// echo $slq;
echo '<script>location.href = "students.php"</script>';
}
else if(isset($_GET['department']) && isset($_GET['class'])){
$cl = $_SESSION['username'] . "_" . $_GET['department'];
$cq = "DELETE From ".$cl." where codename = '".$_GET['class']."'";
$si = $_SESSION['username'] . "_" . $_GET['department'] ."_students";
$sq = "SELECT collegeid FROM ".$si;
$result = mysqli_query($conn, $sq);
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result))
{
$sl = $_SESSION['username'] . "_" . $_GET['department'] . "_" . $row['collegeid'];
$slq = "ALTER TABLE $sl DROP COLUMN ". $_GET['class'];
mysqli_query($conn, $slq);
}
}
mysqli_query($conn, $cq);
echo '<script>location.href = "classes.php"</script>';
}
else if(isset($_GET['department'])){
$dl = $_SESSION['username'] . "_departments";
$cl = $_SESSION['username'] . "_" . $_GET['department'];
$cq = "DROP Table IF EXISTS ".$cl;
$si = $_SESSION['username'] . "_" . $_GET['department'] ."_students";
$siq = "DROP Table IF EXISTS ".$si;
$sq = "SELECT collegeid FROM ".$si;
$result = mysqli_query($conn, $sq);
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result))
{
$sl = $_SESSION['username'] . "_" . $_GET['department'] . "_" . $row['collegeid'];
$slq = "DROP Table IF EXISTS ".$sl;
mysqli_query($conn, $slq);
}
}
$dq = "DELETE FROM ".$dl." where codename = '".$_GET['department']."'";
mysqli_query($conn, $siq);
mysqli_query($conn, $cq);
mysqli_query($conn, $dq);
echo '<script>location.href = "departments.php"</script>';
}
else{
echo "Give A Correct Input";
}
}
else{
echo "No Input Found";
}
}
else{
echo "Needs Admin Permissions";
}
?>