Skip to content

Commit eb8ffb3

Browse files
committed
finished with donors
1 parent 45235f0 commit eb8ffb3

File tree

2 files changed

+97
-1
lines changed

2 files changed

+97
-1
lines changed

donorDelete.php

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<?php
4+
require('connect-db.php');
5+
?>
6+
7+
<head>
8+
<meta charset="utf-8">
9+
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- required to handle IE -->
10+
<meta name="viewport" content="width=device-width, initial-scale=1">
11+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
12+
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
13+
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
14+
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
15+
crossorigin="anonymous"></script>
16+
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
17+
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
18+
crossorigin="anonymous"></script>
19+
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
20+
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
21+
crossorigin="anonymous"></script>
22+
<!-- ICON -->
23+
<link rel="shortcut icon" href="https://pngimg.com/uploads/paw/paw_PNG21.png" type="image/ico" />
24+
<!-- EXTERNAL CSS -->
25+
<link href="./styles/style.css" rel="stylesheet" type="text/css" />
26+
</head>
27+
28+
<?php include "./navbar.php"; ?>
29+
30+
<?php
31+
//checks that the user is logged in
32+
if (isset($_SESSION['user'])){
33+
//checks that there is a course set to edit
34+
if (!isset($_SESSION['id']))
35+
{
36+
echo "<script>
37+
alert('Nothing to delete, returning home');
38+
window.location.href='home.php';
39+
</script>";
40+
}
41+
//checks for post
42+
if ($_SERVER["REQUEST_METHOD"] == "POST")
43+
{
44+
if (!empty($_POST['action']) && ($_POST['action'] == 'Cancel'))
45+
{
46+
unset($_SESSION['id']);
47+
header("Location: donors.php");
48+
}
49+
else
50+
{
51+
$query = "DELETE FROM donors WHERE last_name=:last_name";
52+
$statement = $db->prepare($query);
53+
$statement->bindValue(':last_name', $_SESSION['id']);
54+
$statement->execute();
55+
$statement->closeCursor();
56+
unset($_SESSION['id']);
57+
echo "<script>
58+
alert('User removed from donors');
59+
window.location.href='donors.php';
60+
</script>";
61+
}
62+
63+
}
64+
?>
65+
66+
<div class="container" style="text-align: center;">
67+
</br>
68+
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" name="editForm" method="post">
69+
70+
<h4>Are you sure you want to remove <?php echo "Donor with last name: "; echo $_SESSION['id'];?> as an donor?</h4>
71+
72+
<div class="row">
73+
<div class="form-group col-md">
74+
<button type="submit" class="btn btn-primary">Submit</button>
75+
</div>
76+
</br>
77+
<div class="form-group col-md">
78+
<input type="submit" value="Cancel" name="action" class="btn btn-secondary" />
79+
</div>
80+
</div>
81+
82+
</form>
83+
84+
85+
</div>
86+
87+
<?php
88+
}
89+
else
90+
{
91+
echo "<script>
92+
alert('Permission Denied');
93+
window.location.href='home.php';
94+
</script>";
95+
}
96+
?>

donorEdit.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
if (!empty($_POST['action']) && ($_POST['action'] == 'Cancel'))
5858
{
5959
unset($_SESSION['id']);
60-
header("Location: home.php");
60+
header("Location: donors.php");
6161
}
6262
else
6363
{

0 commit comments

Comments
 (0)