-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path19.delete.php
76 lines (61 loc) · 1.6 KB
/
19.delete.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
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
include "db_secure.php";
if (!($connection = @mysql_connect(DB_HOST, 'conference', 'conference'))) {
showerror();
}
if (!mysql_select_db('conference', $connection)) {
showerror();
}
$deleted = false;
if ($_POST['delete'] == 'Submit') {
$id = mysqlclean($_POST, "registrant_id", 11, $connection);
if (!isset($id)) {
die('no id given');
}
$query = "DELETE FROM registrations2 WHERE id = {$id}";
// echo $query;
if (!mysql_query($query)) {
showerror();
exit;
}
if (mysql_affected_rows() != 1) {
// something bad has happened
exit;
}
$deleted = true;
unset($_POST['delete']);
}
$query = "SELECT * FROM registrations2 ORDER BY name";
// echo $query;
if (!$result = mysql_query($query)) {
showerror();
}
$registrants = array();
if (mysql_num_rows($result) > 0) {
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$registrants[$row['id']] = $row;
}
}
?>
<html>
<head>
<title>Delete Registration form</title>
<script type="text/javascript">
function confirmDelete() {
}
</script>
</head>
<body>
<form action="19.delete.php" method="POST">
Registrant:<select name="registrant_id">
<?php foreach ($registrants as $id => $registrant): ?>
<option value="<?php echo $id; ?>"><?php echo $registrant['name']; ?></option>
<?php endforeach; ?>
</select><br>
<input type="submit" name ="delete" value="Submit" onclick="confirm('Are you sure you want to delete this registrant?')">
</form>
<?php if ($deleted): ?>
Deleted registrant with id <?php echo $id; ?>.
<?php endif; ?>
</body>
</html>