-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.jsp
More file actions
118 lines (114 loc) · 3.34 KB
/
delete.jsp
File metadata and controls
118 lines (114 loc) · 3.34 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<%@ page import="java.sql.*" %>
<html>
<head>
<title>FeedBack Management System</title>
<style>
body {
background-color: #f5f5f5;
font-family: Arial, sans-serif;
}
.nav {
background-color: #007bff;
padding: 10px;
margin-bottom: 20px;
}
.nav a {
color: white;
text-decoration: none;
margin: 0 10px;
}
.nav a:hover {
text-decoration: underline;
}
.container {
max-width: 600px;
margin: 0 auto;
}
h1 {
text-align: center;
color: #333;
}
form {
padding: 20px;
background-color: rgba(255, 255, 255, 0.8);
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
input[type="email"],
input[type="submit"] {
width: 100%;
padding: 10px;
margin: 5px 0;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
}
input[type="email"]:focus,
input[type="submit"]:focus {
outline: none;
border-color: #007bff;
box-shadow: 0 0 5px #007bff;
}
input[type="submit"] {
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
transition: background-color 0.3s;
}
input[type="submit"]:hover {
background-color: #0056b3;
}
</style>
<script>
function confirmDelete() {
return confirm("Are you sure you want to delete?");
}
</script>
</head>
<body>
<center>
<div class="nav">
<a href="home.jsp">Home</a>
<a href="view.jsp">View Feedbacks</a>
</div>
<br><br/>
<br><br/>
<br><br/>
<div class="container">
<h1>Delete Your Feedback</h1>
<%
String un = (String) session.getAttribute("un");
if (un == null) {
response.sendRedirect("index.jsp");
}
%>
<form method="POST">
<input type="email" name="email" placeholder="Enter your registered email ID" required>
<br><br>
<input type="submit" value="Delete" name="btn" onclick="return confirmDelete()">
<br><br>
</form>
<%
if (request.getParameter("btn") != null) {
String email = request.getParameter("email");
try {
DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
String url = "jdbc:mysql://localhost:3306/feedback_app";
Connection con = DriverManager.getConnection(url, "root", "amishaka");
String sql = "DELETE FROM student WHERE email=?";
PreparedStatement pst = con.prepareStatement(sql);
pst.setString(1, email);
int r = pst.executeUpdate();
out.println(r + " record deleted");
con.close();
} catch (SQLException e) {
out.println("SQL issue: " + e);
}
}
%>
</div>
</center>
</body>
</html>