-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadminDashboard.jsp
More file actions
117 lines (105 loc) · 3.44 KB
/
adminDashboard.jsp
File metadata and controls
117 lines (105 loc) · 3.44 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
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%
String email = (String) session.getAttribute("username");
String userType = (String) session.getAttribute("userType");
String username = "";
String userId = "";
if (email == null) {
response.sendRedirect("index.html");
}
boolean userFound = false;
try {
// Database connection
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/LibraryDB", "root", "Mahadev07ji$");
// Query to fetch user details
String query = "SELECT id, username, email FROM "+ userType +" WHERE email = ?";
PreparedStatement ps = con.prepareStatement(query);
ps.setString(1, email);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
userId = rs.getString("id");
username = rs.getString("username");
email = rs.getString("email");
userFound = true;
}
rs.close();
ps.close();
con.close();
} catch (Exception e) {
out.println("<h3>Error: " + e.getMessage() + "</h3>");
}
%>
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard</title>
<link rel="stylesheet" href="dashboard.css">
<link rel="stylesheet" href="userStyle.css">
<style>
.form-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 30vh;
background: rgba(0, 0, 0, 0.5);
/* Dark background with transparency */
padding: 30px;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
width: 80%;
max-width: 400px;
margin: auto;
}
.toolbar a {
display: block;
color: white;
padding: 14px 20px;
text-decoration: none;
display: inline-block;
}
.toolbar .active {
background-color: #d9c8c8;
color: rgb(18, 18, 18);
border-radius: 10px;
}
.user-detail {
font-size: 1em;
text-shadow: 2px 2px 5px black;
margin-bottom: 20px;
}
</style>
</head>
<body style="background-image: url('admin-background.jpg'); background-size: cover; background-position: center;">
<div class="toolbar">
<a href="adminDashboard.jsp">Admin Dashboard</a>
<a href="addBook.jsp">Add Books</a>
<a href="selectBookId.jsp">Update Book</a>
<a href="deleteBook.jsp">Delete Book</a>
<a href="issueBook.jsp">Issue Book</a>
<a href="returnBook.jsp">Return Book</a>
<a href="logout.jsp">Logout</a>
</div>
<div class="container">
<h1 class="dashboard-title">Welcome To Admin Dashboard</h1>
<div class="form-container">
<h2 style="font-size: 2em; color: gold;">Admin Detail</h2>
<div class="user-detail">
<% if (userFound) { %>
<p><strong>User ID:</strong> <%= userId %></p>
<p><strong>Username:</strong> <%= username %></p>
<p><strong>Email:</strong> <%= email %></p>
<% } else { %>
<p>No user found with the username: <%= username %></p>
<% } %>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>