-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeletesheet.php
More file actions
70 lines (69 loc) · 2.09 KB
/
Copy pathdeletesheet.php
File metadata and controls
70 lines (69 loc) · 2.09 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
<?php
require "includes/header.php";
$userid = $_SESSION['userid'];
$sheetid = $_GET['sheetid'];
// CONNECT TO DATABASE
include 'includes/library.php';
$pdo = connectdb();
// GET SIGNUP SHEET INFO
$query = "SELECT * FROM `signin_info` WHERE userid=?";
$stmt = $pdo->prepare($query);
$stmt->execute([$userid]);
$results = $stmt->fetch();
// GET SLOT INFO
$query = "SELECT * FROM slot_info where sheetid=?";
$stmt=$pdo->prepare($query);
$slots = $stmt->execute([$sheetid]);
$slots = $stmt->fetchAll();
// ERROR VERIFICATION
if (isset($_POST['delete'])) {
$query = "DELETE FROM `signin_info` WHERE sheetid=?";
$stmt = $pdo->prepare($query)->execute([$sheetid]);
// REDIRECT
header("Location:mystuffview.php");
exit();
} else if (isset($_POST["previous"])) {
// REDIRECT
header("Location:mystuffview.php");
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php $page_title = "Delete Sheet"; ?>
<?php include "includes/metadata.php" ?>
</head>
<body>
<section class="delete">
<form method="POST">
<h2>Delete Your Sheet</h2>
<div>
<p class="label">Sheet Title</p>
<p><?php echo $results['title']; ?></p>
</div>
<div>
<p class="label">Description</p>
<p><?php echo $results['description']; ?></p>
</div>
<div>
<p class="label">Time Slots</p>
<div class="inforows">
<?php if($slots==null):?><p>You have not signed up in any slots</p><?php endif ?>
<?php foreach($slots as $r):?>
<div class="sbox">
<div>
<p>Title: <?php echo "$r[title]";?></p>
<p>Date and time: <?php echo "$r[timeslot]";?></p>
</div>
</div>
<?php endforeach ?>
</div>
</div>
<button id="delete" name='delete'>Delete the Sheet </button>
<button id="previous" name="previous"><a href="mystuffview.php">Previous page</a></button>
</form>
</section>
<?php include "includes/footer.php" ?>
</body>
</html>