-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete-election.php
40 lines (31 loc) · 1.52 KB
/
delete-election.php
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
<?php
// Include your database connection file
include('connection.php');
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['deleteElection'])) {
// Fetch SectionBatch from the URL
$SectionBatch = $_POST['SectionBatch'];
// Delete data from applycandidate table
$deleteApplyCandidateQuery = "DELETE FROM applycandidate WHERE SectionBatch = '$SectionBatch'";
mysqli_query($conn, $deleteApplyCandidateQuery);
// Delete data from candidates table
$deleteCandidatesQuery = "DELETE FROM candidates WHERE SectionBatch = '$SectionBatch'";
mysqli_query($conn, $deleteCandidatesQuery);
// Delete data from election_data table
$deleteElectionDataQuery = "DELETE FROM election_data WHERE SectionBatch = '$SectionBatch'";
mysqli_query($conn, $deleteElectionDataQuery);
// Delete data from election_settings table
$deleteElectionSettingsQuery = "DELETE FROM election_settings WHERE SectionBatch = '$SectionBatch'";
mysqli_query($conn, $deleteElectionSettingsQuery);
// Delete data from voters table
$deleteVotersQuery = "DELETE FROM voters WHERE SectionBatch = '$SectionBatch'";
mysqli_query($conn, $deleteVotersQuery);
// Delete data from votes table
$deleteVotesQuery = "DELETE FROM votes WHERE SectionBatch = '$SectionBatch'";
mysqli_query($conn, $deleteVotesQuery);
// Redirect to a suitable page after deletion
header('Location: logout.php'); // Change this to your desired redirect location
exit();
}
// Close the database connection
mysqli_close($conn);
?>