-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeleteStuff.php
More file actions
80 lines (68 loc) · 1.82 KB
/
Copy pathdeleteStuff.php
File metadata and controls
80 lines (68 loc) · 1.82 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
77
78
79
80
<?php
session_start();
require 'databaseConnection.php';
if(!isset($_SESSION['username'])) {
header('Location: login.php');
}
function getMovies() {
global $conn;
$sql = "SELECT movieID, title
FROM movieDatabase
ORDER BY title ASC";
$stmt = $conn -> prepare($sql);
$stmt -> execute();
return $stmt -> fetchAll();
}
if( isset ($_POST['submit']) ) {
try {
$sql = "DELETE FROM movieDatabase
WHERE movieID = :movieID";
$stmt = $conn -> prepare($sql);
$stmt -> execute(array(':movieID'=> $_POST['movieID']));
echo "<div class='adminMessage'> >> Data Deleted!</div>";
}
catch (PDOException $e) {
echo "ERROR: " . $e->getMessage();
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Delete Movies From Database?!</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="ourStyles.css">
</head>
<body>
<div id="header"></div>
<div id="nav">
<h3>Members Area</h3>
<a href="movieSearch.php">Home</a><br>
<a href="editDatabase.php">Add to Database</a><br>
<a href="deleteStuff.php">Delete from Database</a><br>
<a href="changePassword.php">Change Password</a><br>
<a href="logout.php">Logout</a>
</div>
<div class="center">
<table id="login"><form method="post">
<tr><td colspan="2">Delete A Movie</td></tr>
<tr>
<td>Delete A Movie</td>
<td><select size=1 name="movieID">
<option value="-1">Choose A Movie Title</option>
<?php
$movieTitles = getMovies();
foreach ($movieTitles as $movie) {
echo "<option value='" . $movie['movieID'] . "'>" . $movie['title'] . "</option>";
}
?>
</select></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="DELETE" name="submit"><img src="popcorn-icon.png"></td>
</tr>
</form></table>
</div>
</body>
</html>
<?php $conn = null; ?>