code Copy code
<!-- Bootstrap 5 CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" />
<!-- Simple DataTables CSS -->
<link href="https://cdn.jsdelivr.net/npm/simple-datatables@7.1.2/dist/style.css" rel="stylesheet" />
<!-- Bootstrap Icons -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet" />
<style>
body { background: #f9fafb; }
.card-icon {
font-size: 2.4rem;
opacity: 0.3;
}
.card:hover {
box-shadow: 0 10px 20px rgb(0 0 0 / 0.12);
transition: all 0.3s ease;
}
.action-btns button {
margin-right: 5px;
}
</style>
code Copy code
<?php if (isset($_SESSION['error'])): ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<?=htmlspecialchars($_SESSION['error'])?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php unset($_SESSION['error']); ?>
<?php endif; ?>
<?php if (isset($_SESSION['success'])): ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<?=htmlspecialchars($_SESSION['success'])?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php unset($_SESSION['success']); ?>
<?php endif; ?>
<!-- Stats Cards -->
<div class="row g-4 mb-5">
<div class="col-md-3">
<div class="card shadow-sm p-3">
<div class="d-flex justify-content-between align-items-center">
<div>
<h6 class="text-uppercase text-muted">Total Users</h6>
<h3><?= $totalUsers ?></h3>
</div>
<i class="bi bi-people-fill card-icon"></i>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card shadow-sm p-3">
<div class="d-flex justify-content-between align-items-center">
<div>
<h6 class="text-uppercase text-muted">Total Books</h6>
<h3><?= $totalBooks ?></h3>
</div>
<i class="bi bi-book-fill card-icon"></i>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card shadow-sm p-3">
<div class="d-flex justify-content-between align-items-center">
<div>
<h6 class="text-uppercase text-muted">Borrowed Books</h6>
<h3><?= $totalBorrowed ?></h3>
</div>
<i class="bi bi-journal-arrow-up card-icon"></i>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card shadow-sm p-3">
<div class="d-flex justify-content-between align-items-center">
<div>
<h6 class="text-uppercase text-muted">Admins</h6>
<h3><?= $totalAdmins ?></h3>
</div>
<i class="bi bi-shield-lock-fill card-icon"></i>
</div>
</div>
</div>
</div>
<!-- Recent Borrow Records -->
<h4 class="mb-3">Recent Borrow Records</h4>
<table class="table table-striped" id="recentBorrowsTable">
<thead>
<tr>
<th>ID</th>
<th>User</th>
<th>Book</th>
<th>Borrow Date</th>
<th>Due Date</th>
<th>Return Date</th>
<th>Fine</th>
</tr>
</thead>
<tbody>
<?php foreach($recentBorrows as $r): ?>
<tr>
<td><?= $r['id'] ?></td>
<td><?= htmlspecialchars($r['username']) ?></td>
<td><?= htmlspecialchars($r['title']) ?></td>
<td><?= $r['borrow_date'] ?></td>
<td><?= $r['due_date'] ?></td>
<td><?= $r['return_date'] ?? '-' ?></td>
<td><?= $r['fine'] ? '$'.number_format($r['fine'], 2) : '-' ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<hr>
<!-- Users Management -->
<h4 class="mb-3">Users</h4>
<button class="btn btn-primary mb-3" data-bs-toggle="modal" data-bs-target="#addUserModal">
<i class="bi bi-person-plus-fill"></i> Add User
</button>
<table class="table table-hover" id="usersTable">
<thead>
<tr>
<th>ID</th>
<th>Username</th>
<th>Role</th>
<th>Created At</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($users as $u): ?>
<tr>
<td><?= $u['id'] ?></td>
<td><?= htmlspecialchars($u['username']) ?></td>
<td>
<?php if ($u['role']=='admin'): ?>
<span class="badge bg-danger">Admin</span>
<?php else: ?>
<span class="badge bg-secondary">Member</span>
<?php endif ?>
</td>
<td><?= $u['created_at'] ?></td>
<td class="action-btns">
<?php if($u['id']!=1): ?>
<form method="post" style="display:inline-block" onsubmit="return confirm('Delete user <?=htmlspecialchars(addslashes($u['username']))?>?');">
<input type="hidden" name="delete_user" value="<?= $u['id'] ?>">
<button class="btn btn-sm btn-danger"><i class="bi bi-trash-fill"></i></button>
</form>
<?php else: ?>
<span class="text-muted">Admin</span>
<?php endif ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<hr>
<!-- Books Management -->
<h4 class="mb-3">Books Inventory</h4>
<button class="btn btn-success mb-3" data-bs-toggle="modal" data-bs-target="#addBookModal">
<i class="bi bi-book-fill"></i> Add Book
</button>
<table class="table table-hover" id="booksTable">
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>Author</th>
<th>Category</th>
<th>Total Copies</th>
<th>Available Copies</th>
<th>Added On</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach($books as $b): ?>
<tr>
<td><?= $b['id'] ?></td>
<td><?= htmlspecialchars($b['title']) ?></td>
<td><?= htmlspecialchars($b['author']) ?></td>
<td><?= htmlspecialchars($b['category']) ?></td>
<td><?= $b['total_copies'] ?></td>
<td><?= $b['available_copies'] ?></td>
<td><?= $b['created_at'] ?></td>
<td class="action-btns">
<form method="post" style="display:inline-block" onsubmit="return confirm('Delete book <?=htmlspecialchars(addslashes($b['title']))?>?');" >
<input type="hidden" name="delete_book" value="<?= $b['id'] ?>">
<button class="btn btn-sm btn-danger"><i class="bi bi-trash-fill"></i></button>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<hr>
<!-- Borrow Records -->
<h4 class="mb-3">Borrow Records</h4>
<table class="table table-hover" id="borrowRecordsTable">
<thead>
<tr>
<th>ID</th>
<th>Username</th>
<th>Book Title</th>
<th>Borrow Date</th>
<th>Due Date</th>
<th>Return Date</th>
<th>Fine</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach($borrow_records as $br): ?>
<tr>
<td><?= $br['id'] ?></td>
<td><?= htmlspecialchars($br['username']) ?></td>
<td><?= htmlspecialchars($br['title']) ?></td>
<td><?= $br['borrow_date'] ?></td>
<td><?= $br['due_date'] ?></td>
<td><?= $br['return_date'] ?? '-' ?></td>
<td><?= $br['fine'] ? '$'.number_format($br['fine'],2) : '-' ?></td>
<td class="action-btns">
<?php if(empty($br['return_date'])): ?>
<form method="post" onsubmit="return confirm('Mark this book as returned?');" style="display:inline-block;">
<input type="hidden" name="record_id" value="<?= $br['id'] ?>">
<button name="return_book" class="btn btn-sm btn-primary"><i class="bi bi-arrow-return-left"></i> Return</button>
</form>
<?php else: ?>
<span class="badge bg-success">Returned</span>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
Show full message · 538 lines Assistant2025-04-22 05:21 UTC Copy response
To enhance your Library Management System's admin dashboard by adding Update Book functionality (and similarly, you could add Update User), you need to:
Add an Edit button in the Books table.
Create a modal form for editing the book details pre-filled with current data.
Handle the POST request for updating the book record.
Show appropriate success/error messages.
1. Add an Edit Button in Books Table
In your existing books table, add another button besides Delete for "Edit". Change the <td class="action-btns"> block in the Books Inventory section to:
php Copy code
<td class="action-btns">
<button
type="button"
class="btn btn-sm btn-warning edit-book-btn"
data-bs-toggle="modal"
data-bs-target="#editBookModal"
data-id="<?= $b['id'] ?>"
data-title="<?= htmlspecialchars($b['title'], ENT_QUOTES) ?>"
data-author="<?= htmlspecialchars($b['author'], ENT_QUOTES) ?>"
data-category="<?= htmlspecialchars($b['category'], ENT_QUOTES) ?>"
data-total-copies="<?= $b['total_copies'] ?>"
data-available-copies="<?= $b['available_copies'] ?>"
>
<i class="bi bi-pencil-fill"></i> Edit
</button>
<form method="post" style="display:inline-block" onsubmit="return confirm('Delete book <?=htmlspecialchars(addslashes($b['title']))?>?');" >
<input type="hidden" name="delete_book" value="<?= $b['id'] ?>">
<button class="btn btn-sm btn-danger"><i class="bi bi-trash-fill"></i></button>
</form>
</td>
2. Create Edit Book Modal
Right after your Add Book Modal, add:
code Copy code
<!-- Bootstrap 5 CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" />
<!-- Simple DataTables CSS -->
<link href="https://cdn.jsdelivr.net/npm/simple-datatables@7.1.2/dist/style.css" rel="stylesheet" />
<!-- Bootstrap Icons -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet" />
<style>
body { background: #f9fafb; }
.card-icon {
font-size: 2.4rem;
opacity: 0.3;
}
.card:hover {
box-shadow: 0 10px 20px rgb(0 0 0 / 0.12);
transition: all 0.3s ease;
}
.action-btns button {
margin-right: 5px;
}
</style>
Show full message · 538 lines Assistant2025-04-22 05:24 UTC Copy response
Certainly! I've integrated the Edit Book functionality into your existing admin dashboard code, including:
An Edit button for each book in the table.
A modal form for editing book details, pre-filled with the relevant book's data.
PHP POST handling to update the book in the database with proper checks.
Adjusted JavaScript to populate the modal on "Edit" button click.
Here's your full updated admin dashboard code with these features added:
Show full message · 660 lines Show full message · 161 lines Assistant2025-04-22 05:32 UTC Copy response
To add a library-related image from Google (or any image URL) to your login page alongside your form, you can simply include an <img> tag in your HTML and style it appropriately.
Here's how you can do it:
Pick a good library image URL
For example, you can use a free image from Unsplash via their CDN:
code Copy code
https://images.unsplash.com/photo-1524995997946-a1c2e315a42f?auto=format&fit=crop&w=800&q=80
(or replace with any image URL you like).
Modify your HTML and CSS to display the image side-by-side with the form on larger screens and stacked on smaller screens, for a nice responsive login layout.
Updated code snippet including the image
Wrap your form and image inside a flex container.
Replace the body inner part with this:
html Copy code
<div class="login-wrapper d-flex flex-column flex-md-row align-items-center justify-content-center gap-4">
<!-- Image section -->
<div class="login-image-wrapper">
<img src="https://images.unsplash.com/photo-1524995997946-a1c2e315a42f?auto=format&fit=crop&w=800&q=80" alt="Library" class="login-image" />
</div>
<!-- Login form section -->
<div class="login-container shadow-lg">
<h2>User Login</h2>
<?php if ($error): ?>
<div class="alert alert-danger"><?=htmlspecialchars($error)?></div>
<?php endif; ?>
<form method="post" novalidate autocomplete="off">
<div class="mb-4">
<label for="username" class="form-label">Username</label>
<input id="username" type="text" name="username" class="form-control" placeholder="Enter your username" required value="<?=htmlspecialchars($_POST['username'] ?? '')?>" />
</div>
<div class="mb-5">
<label for="password" class="form-label">Password</label>
<input id="password" type="password" name="password" class="form-control" placeholder="Enter your password" required />
</div>
<button type="submit" class="btn btn-primary">Log In</button>
</form>
</div>
</div>
Assistant2025-04-22 05:33 UTC Copy response
Certainly! Here's the full updated login page code with a beautiful library image added side-by-side the login form on larger screens and stacked on smaller screens:
Show full message · 233 lines
code Copy code
/* Wrapper for image + form */
.login-wrapper {
min-height: 100vh;
max-width: 900px;
margin: 0 auto;
display: flex;
flex-direction: column;
gap: 30px;
justify-content: center;
align-items: center;
}
@media(min-width: 768px) {
.login-wrapper {
flex-direction: row;
gap: 60px;
}
}
/* Image wrapper */
.login-image-wrapper {
flex: 1;
max-width: 450px;
display: flex;
justify-content: center;
align-items: center;
}
.login-image {
width: 100%;
height: auto;
border-radius: 15px;
box-shadow: 0 15px 40px rgba(0,0,0,0.3);
object-fit: cover;
}
/* Form container */
.login-container {
flex: 1;
max-width: 420px;
background: rgba(255, 255, 255, 0.1);
padding: 40px 50px;
border-radius: 15px;
box-shadow: 0 15px 40px rgba(0,0,0,0.3);
backdrop-filter: blur(10px);
animation: fadeIn 1s ease forwards;
width: 100%;
}
h2 {
font-weight: 600;
margin-bottom: 30px;
text-align: center;
letter-spacing: 1.5px;
text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
label {
font-weight: 600;
letter-spacing: 0.8px;
color: #e0e0e0;
}
.form-control {
background: rgba(255,255,255,0.2);
border: none;
border-radius: 10px;
color: #fff;
padding: 15px 20px;
font-size: 1rem;
box-shadow: inset 2px 2px 4px rgba(255,255,255,0.3);
transition: background-color 0.3s ease;
}
.form-control:focus {
background: rgba(255,255,255,0.4);
color: #222;
box-shadow: 0 0 10px #9155fd;
outline: none;
}
.btn-primary {
background: #9155fd;
border: none;
padding: 15px 0;
font-weight: 600;
font-size: 1.1rem;
border-radius: 10px;
width: 100%;
transition: background-color 0.3s ease;
box-shadow: 0 5px 15px rgba(145,85,253,0.6);
}
.btn-primary:hover {
background: #682bdf;
box-shadow: 0 8px 25px rgba(104,43,223,0.7);
}
.alert-danger {
background-color: rgba(255, 72, 66, 0.85);
border-radius: 8px;
padding: 12px 20px;
font-weight: 600;
margin-bottom: 20px;
text-align: center;
box-shadow: 0 3px 10px rgba(255,72,66,0.5);
}
@keyframes fadeIn {
0% {opacity: 0; transform: translateY(20px);}
100% {opacity: 1; transform: translateY(0);}
}
::placeholder {
color: rgba(255,255,255,0.7);
font-weight: 400;
}
</style>
Show full message · 215 lines Assistant2025-04-22 05:48 UTC Copy response
Sure! You can add a heading above the library image inside the .login-image-wrapper div. Here’s how you can modify that part to include a title like "Library Management System" above the image:
Replace this part in your HTML:
html Copy code
<div class="login-image-wrapper">
<img src="https://images.unsplash.com/photo-1524995997946-a1c2e315a42f?auto=format&fit=crop&w=800&q=80" alt="Library" class="login-image" />
</div>
with this:
html Copy code
<div class="login-image-wrapper text-center">
<h1 class="mb-4 fw-bold" style="text-shadow: 0 2px 8px rgba(0,0,0,0.5); color: #fff;">Library Management System</h1>
<img src="https://images.unsplash.com/photo-1524995997946-a1c2e315a42f?auto=format&fit=crop&w=800&q=80" alt="Library" class="login-image" />
</div>
This places the text above the image, centers it, and applies some style to make it look good on the gradient background.
Full final snippet of .login-image-wrapper:
html Copy code
<div class="login-image-wrapper text-center">
<h1 class="mb-4 fw-bold" style="text-shadow: 0 2px 8px rgba(0,0,0,0.5); color: #fff;">Library Management System</h1>
<img src="https://images.unsplash.com/photo-1524995997946-a1c2e315a42f?auto=format&fit=crop&w=800&q=80" alt="Library" class="login-image" />
</div>
Explanation:
text-center: centers the heading.
mb-4: margin below the heading for some spacing.
fw-bold: makes the heading bold.
Inline style adds a subtle black text-shadow for readability on the gradient background.
The color is white for visibility.
If you want, I can give you the entire updated login page code with this heading included as well. Just let me know!
Assistant2025-04-22 05:48 UTC Copy response
Certainly! Below is your full updated login page code with the added heading "Library Management System" above the library image on the login page:
Show full message · 238 lines change the color and make the text looks more appealing
Assistant2025-04-22 05:51 UTC Copy response
Certainly! To make the heading "Library Management System" more appealing, we can:
Use a gradient color effect on the text.
Add subtle animations (e.g., fade in or slide in).
Use a nice font weight and spacing.
Add a slight glowing text-shadow.
I'll update the <h1> styling accordingly.
Updated CSS for the heading inside .login-image-wrapper h1:
css Copy code
.login-image-wrapper h1 {
margin-bottom: 24px;
font-weight: 800;
font-size: 2.8rem;
text-align: center;
background: linear-gradient(45deg, #6a11cb, #2575fc);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
-webkit-text-fill-color: transparent;
letter-spacing: 2px;
text-shadow: 0 0 8px rgba(101, 81, 224, 0.6);
animation: glowText 2s ease-in-out infinite alternate;
}
@keyframes glowText {
0% {
text-shadow:
0 0 8px rgba(101, 81, 224, 0.6),
0 0 20px rgba(101, 81, 224, 0.5),
0 0 30px rgba(101, 81, 224, 0.4);
}
100% {
text-shadow:
0 0 12px rgba(101, 81, 224, 0.9),
0 0 28px rgba(101, 81, 224, 0.7),
0 0 40px rgba(101, 81, 224, 0.6);
}
}
How to apply:
Replace the existing .login-image-wrapper h1 CSS block with the above styling in your <style>.
What it looks like:
The heading text has a purple-to-blue gradient fill.
The actual text color is transparent but filled by the gradient (modern CSS text gradient trick).
The glowing shadow slowly animates, giving a subtle pulsating neon glow effect.
Full relevant CSS snippet snippet with changes in context:
Assistant2025-04-22 05:51 UTC Copy response
Certainly! Below is the full updated login page code with the enhanced and animated gradient glowing heading "Library Management System" applied above the image:
Show full message · 260 lines color is very bad is not visible
Assistant2025-04-22 05:53 UTC Copy response
Got it! If the gradient glow text is not clearly visible on your background, we can adjust the style for better readability:
Use a strong solid color instead of gradient or
Use a brighter gradient with white glow/highlight
Add a dark semi-transparent backdrop behind the text to increase contrast
Here is an improved styling version for the heading to make it bright, crisp, and very visible:
Replace the .login-image-wrapper h1 CSS with this:
css Copy code
.login-image-wrapper h1 {
margin-bottom: 24px;
font-weight: 800;
font-size: 2.8rem;
text-align: center;
color: #fff;
letter-spacing: 2px;
text-shadow:
0 0 8px rgba(255, 255, 255, 0.8),
0 0 20px rgba(255, 255, 255, 0.6),
0 0 30px rgba(255, 255, 255, 0.5);
background-color: rgba(0, 0, 0, 0.25);
padding: 10px 20px;
border-radius: 12px;
box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}
Why this works better:
Color : Pure white text #fff makes the text sharp.
Text shadow : a strong white glow outlines the letters.
Background color : subtle black transparent rectangle behind the text improves contrast against the image/background.
Padding and border-radius : makes the background shape smooth and spaced nicely.
Box shadow : adds a subtle shadow around the black backdrop to lift the text visually.
Paste this updated snippet into your CSS <style> block replacing the previous heading style:
css Copy code
.login-image-wrapper h1 {
margin-bottom: 24px;
font-weight: 800;
font-size: 2.8rem;
text-align: center;
color: #fff;
letter-spacing: 2px;
text-shadow:
0 0 8px rgba(255, 255, 255, 0.8),
0 0 20px rgba(255, 255, 255, 0.6),
0 0 30px rgba(255, 255, 255, 0.5);
background-color: rgba(0, 0, 0, 0.25);
padding: 10px 20px;
border-radius: 12px;
box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}
If you want, I can send you the full updated login page code with this improved heading style included. Would you like that?
Assistant2025-04-22 05:53 UTC Copy response
Certainly! Here is the full updated login page code with the improved, highly visible white glowing heading "Library Management System" above the image:
Show full message · 243 lines Show full message · 235 lines Assistant2025-04-22 05:55 UTC Copy response
You can add a “Register” link below the login form so users can easily navigate to the registration page without having to open register.php separately.
How to do this:
Add a small text below the login button (inside .login-container) like:
html Copy code
<div class="text-center mt-3">
<a href="register.php" class="text-white" style="text-decoration: underline;">
Don't have an account? Register here
</a>
</div>
Exact place to add:
Put this snippet right after the closing </form> tag inside .login-container, like so:
html Copy code
<form method="post" novalidate autocomplete="off">
<!-- username & password inputs, submit button here -->
...
<button type="submit" class="btn btn-primary">Log In</button>
</form>
<div class="text-center mt-3">
<a href="register.php" class="text-white" style="text-decoration: underline;">
Don't have an account? Register here
</a>
</div>
Full section for login container for clarity:
html Copy code
<div class="login-container shadow-lg">
<h2>User Login</h2>
<?php if ($error): ?>
<div class="alert alert-danger"><?=htmlspecialchars($error)?></div>
<?php endif; ?>
<form method="post" novalidate autocomplete="off">
<div class="mb-4">
<label for="username" class="form-label">Username</label>
<input id="username" type="text" name="username" class="form-control" placeholder="Enter your username" required value="<?=htmlspecialchars($_POST['username'] ?? '')?>" />
</div>
<div class="mb-5">
<label for="password" class="form-label">Password</label>
<input id="password" type="password" name="password" class="form-control" placeholder="Enter your password" required />
</div>
<button type="submit" class="btn btn-primary">Log In</button>
</form>
<div class="text-center mt-3">
<a href="register.php" class="text-white" style="text-decoration: underline;">
Don't have an account? Register here
</a>
</div>
</div>
This will display a nicely formatted registration link under the login form.
If you want, I can provide the fully updated login page code including this modification. Would you like that?
Assistant2025-04-22 05:56 UTC Copy response
Certainly! Here's the full updated login page code with a convenient "Register" link added below the login form, allowing users to navigate to register.php easily:
Show full message · 270 lines Copy first response
Turns (12) <!-- Edit Book Modal -->
<div class="modal fade" id="editBookModal" tabindex="-1" aria-labelledby="editBookModalLabel" aria-hidden="true">
<div class="modal-dialog">
<form method="post" class="modal-content needs-validation" novalidate>
<input type="hidden" name="action" value="edit_book"/>
<input type="hidden" name="book_id" id="edit-book-id" />
<div class="modal-header">
<h5 class="modal-title" id="editBookModalLabel">Edit Book</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label for="edit-title" class="form-label">Title *</label>
<input type="text" class="form-control" id="edit-title" name="title" required />
<div class="invalid-feedback">Please enter a title.</div>
</div>
<div class="mb-3">
<label for="edit-author" class="form-label">Author *</label>
<input type="text" class="form-control" id="edit-author" name="author" required />
<div class="invalid-feedback">Please enter the author.</div>
</div>
<div class="mb-3">
<label for="edit-category" class="form-label">Category</label>
<input type="text" class="form-control" id="edit-category" name="category" />
</div>
<div class="mb-3">
<label for="edit-total_copies" class="form-label">Total Copies *</label>
<input type="number" min="1" class="form-control" id="edit-total_copies" name="total_copies" required />
<div class="invalid-feedback">Please enter total copies (>=1).</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-warning">Update Book</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
3. JavaScript to Populate Edit Modal with Existing Data In your <script> tag, add:
js Copy code
document.querySelectorAll('.edit-book-btn').forEach(button => {
button.addEventListener('click', () => {
const modal = document.getElementById('editBookModal');
modal.querySelector('#edit-book-id').value = button.dataset.id;
modal.querySelector('#edit-title').value = button.dataset.title;
modal.querySelector('#edit-author').value = button.dataset.author;
modal.querySelector('#edit-category').value = button.dataset.category;
modal.querySelector('#edit-total_copies').value = button.dataset.totalCopies;
});
});
This fills the modal form fields with information from the clicked book's data attributes.
4. PHP: Handle edit_book POST Request Add this in your PHP POST request handler where you check for $_POST['action']:
php Copy code
elseif ($action === 'edit_book') {
$book_id = (int)($_POST['book_id'] ?? 0);
$title = trim($_POST['title'] ?? '');
$author = trim($_POST['author'] ?? '');
$category = trim($_POST['category'] ?? '');
$total_copies = (int)($_POST['total_copies'] ?? 1);
$total_copies = max(1, $total_copies);
if ($book_id <= 0 || $title === '' || $author === '' || $total_copies < 1) {
$_SESSION['error'] = 'Invalid input for updating book.';
} else {
// Get existing book data
$stmt = $pdo->prepare("SELECT total_copies, available_copies FROM books WHERE id = ?");
$stmt->execute([$book_id]);
$book = $stmt->fetch();
if (!$book) {
$_SESSION['error'] = 'Book not found.';
} else {
// Calculate difference in total copies
$copies_diff = $total_copies - $book['total_copies'];
$new_available_copies = $book['available_copies'] + $copies_diff;
// Ensure available copies doesn't go below zero
if ($new_available_copies < 0) {
$_SESSION['error'] = 'Cannot reduce total copies below the number of currently borrowed books.';
} else {
$stmt = $pdo->prepare("UPDATE books SET title = ?, author = ?, category = ?, total_copies = ?, available_copies = ? WHERE id = ?");
$stmt->execute([$title, $author, $category, $total_copies, $new_available_copies, $book_id]);
$_SESSION['success'] = "Book '$title' updated successfully.";
}
}
}
}
Optional: Update User Feature You can replicate the similar steps for the users table - add an "Edit User" button with a modal, and handle updating username and role. Password update would require special care (leave blank for no change or have a separate password reset feature).
Summary This enhances the admin dashboard by:
Allowing admins to update book metadata and stock counts safely.
Prevents setting total copies less than currently borrowed books.
Provides UI feedback with modals and success/error messages.
Keeps your UX consistent using Bootstrap modals and existing styles.
If you'd like, I can also help add other features like admin user updates, borrowing limit management, or more detailed reports!
<?php if (isset($_SESSION['error'])): ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<?=htmlspecialchars($_SESSION['error'])?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php unset($_SESSION['error']); ?>
<?php endif; ?>
<?php if (isset($_SESSION['success'])): ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<?=htmlspecialchars($_SESSION['success'])?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php unset($_SESSION['success']); ?>
<?php endif; ?>
<!-- Stats Cards -->
<div class="row g-4 mb-5">
<div class="col-md-3">
<div class="card shadow-sm p-3">
<div class="d-flex justify-content-between align-items-center">
<div>
<h6 class="text-uppercase text-muted">Total Users</h6>
<h3><?= $totalUsers ?></h3>
</div>
<i class="bi bi-people-fill card-icon"></i>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card shadow-sm p-3">
<div class="d-flex justify-content-between align-items-center">
<div>
<h6 class="text-uppercase text-muted">Total Books</h6>
<h3><?= $totalBooks ?></h3>
</div>
<i class="bi bi-book-fill card-icon"></i>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card shadow-sm p-3">
<div class="d-flex justify-content-between align-items-center">
<div>
<h6 class="text-uppercase text-muted">Borrowed Books</h6>
<h3><?= $totalBorrowed ?></h3>
</div>
<i class="bi bi-journal-arrow-up card-icon"></i>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card shadow-sm p-3">
<div class="d-flex justify-content-between align-items-center">
<div>
<h6 class="text-uppercase text-muted">Admins</h6>
<h3><?= $totalAdmins ?></h3>
</div>
<i class="bi bi-shield-lock-fill card-icon"></i>
</div>
</div>
</div>
</div>
<!-- Recent Borrow Records -->
<h4 class="mb-3">Recent Borrow Records</h4>
<table class="table table-striped" id="recentBorrowsTable">
<thead>
<tr>
<th>ID</th>
<th>User</th>
<th>Book</th>
<th>Borrow Date</th>
<th>Due Date</th>
<th>Return Date</th>
<th>Fine</th>
</tr>
</thead>
<tbody>
<?php foreach($recentBorrows as $r): ?>
<tr>
<td><?= $r['id'] ?></td>
<td><?= htmlspecialchars($r['username']) ?></td>
<td><?= htmlspecialchars($r['title']) ?></td>
<td><?= $r['borrow_date'] ?></td>
<td><?= $r['due_date'] ?></td>
<td><?= $r['return_date'] ?? '-' ?></td>
<td><?= $r['fine'] ? '$'.number_format($r['fine'], 2) : '-' ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<hr>
<!-- Users Management -->
<h4 class="mb-3">Users</h4>
<button class="btn btn-primary mb-3" data-bs-toggle="modal" data-bs-target="#addUserModal">
<i class="bi bi-person-plus-fill"></i> Add User
</button>
<table class="table table-hover" id="usersTable">
<thead>
<tr>
<th>ID</th>
<th>Username</th>
<th>Role</th>
<th>Created At</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($users as $u): ?>
<tr>
<td><?= $u['id'] ?></td>
<td><?= htmlspecialchars($u['username']) ?></td>
<td>
<?php if ($u['role']=='admin'): ?>
<span class="badge bg-danger">Admin</span>
<?php else: ?>
<span class="badge bg-secondary">Member</span>
<?php endif ?>
</td>
<td><?= $u['created_at'] ?></td>
<td class="action-btns">
<?php if($u['id']!=1): ?>
<form method="post" style="display:inline-block" onsubmit="return confirm('Delete user <?=htmlspecialchars(addslashes($u['username']))?>?');">
<input type="hidden" name="delete_user" value="<?= $u['id'] ?>">
<button class="btn btn-sm btn-danger"><i class="bi bi-trash-fill"></i></button>
</form>
<?php else: ?>
<span class="text-muted">Admin</span>
<?php endif ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<hr>
<!-- Books Management -->
<h4 class="mb-3">Books Inventory</h4>
<button class="btn btn-success mb-3" data-bs-toggle="modal" data-bs-target="#addBookModal">
<i class="bi bi-book-fill"></i> Add Book
</button>
<table class="table table-hover" id="booksTable">
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>Author</th>
<th>Category</th>
<th>Total Copies</th>
<th>Available Copies</th>
<th>Added On</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach($books as $b): ?>
<tr>
<td><?= $b['id'] ?></td>
<td><?= htmlspecialchars($b['title']) ?></td>
<td><?= htmlspecialchars($b['author']) ?></td>
<td><?= htmlspecialchars($b['category']) ?></td>
<td><?= $b['total_copies'] ?></td>
<td><?= $b['available_copies'] ?></td>
<td><?= $b['created_at'] ?></td>
<td class="action-btns">
<form method="post" style="display:inline-block" onsubmit="return confirm('Delete book <?=htmlspecialchars(addslashes($b['title']))?>?');" >
<input type="hidden" name="delete_book" value="<?= $b['id'] ?>">
<button class="btn btn-sm btn-danger"><i class="bi bi-trash-fill"></i></button>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<hr>
<!-- Borrow Records -->
<h4 class="mb-3">Borrow Records</h4>
<table class="table table-hover" id="borrowRecordsTable">
<thead>
<tr>
<th>ID</th>
<th>Username</th>
<th>Book Title</th>
<th>Borrow Date</th>
<th>Due Date</th>
<th>Return Date</th>
<th>Fine</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach($borrow_records as $br): ?>
<tr>
<td><?= $br['id'] ?></td>
<td><?= htmlspecialchars($br['username']) ?></td>
<td><?= htmlspecialchars($br['title']) ?></td>
<td><?= $br['borrow_date'] ?></td>
<td><?= $br['due_date'] ?></td>
<td><?= $br['return_date'] ?? '-' ?></td>
<td><?= $br['fine'] ? '$'.number_format($br['fine'],2) : '-' ?></td>
<td class="action-btns">
<?php if(empty($br['return_date'])): ?>
<form method="post" onsubmit="return confirm('Mark this book as returned?');" style="display:inline-block;">
<input type="hidden" name="record_id" value="<?= $br['id'] ?>">
<button name="return_book" class="btn btn-sm btn-primary"><i class="bi bi-arrow-return-left"></i> Return</button>
</form>
<?php else: ?>
<span class="badge bg-success">Returned</span>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
session_start();
if (!isset($_SESSION['username']) || $_SESSION['role'] !== 'admin') {
header('Location: login.php');
exit;
}
require 'config.php';
// PDO connection
$pdo = new PDO("mysql:host=localhost;dbname=library_db;charset=utf8mb4", 'root', 'root', [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
// Handle POST requests for add/delete/edit/return actions
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['action'])) {
$action = $_POST['action'];
if ($action === 'add_user') {
// Add new user
$username = trim($_POST['username'] ?? '');
$password = $_POST['password'] ?? '';
$role = $_POST['role'] ?? 'member';
if ($username === '' || $password === '' || !in_array($role, ['admin', 'member'])) {
$_SESSION['error'] = 'Invalid input for adding user.';
} else {
// Check if username already exists
$stmt = $pdo->prepare("SELECT COUNT(*) FROM users WHERE username = ?");
$stmt->execute([$username]);
if ($stmt->fetchColumn() > 0) {
$_SESSION['error'] = 'Username already exists.';
} else {
// Hash password
$password_hash = password_hash($password, PASSWORD_DEFAULT);
$stmt = $pdo->prepare("INSERT INTO users (username, password_hash, role, created_at) VALUES (?, ?, ?, NOW())");
$stmt->execute([$username, $password_hash, $role]);
$_SESSION['success'] = "User '$username' added successfully.";
}
}
}
// Removed edit_user handling
elseif (isset($_POST['delete_user'])) {
// Delete user (except main admin id=1)
$user_id = (int)$_POST['delete_user'];
if ($user_id === 1) {
$_SESSION['error'] = 'Cannot delete main admin.';
} else {
$stmt = $pdo->prepare("DELETE FROM users WHERE id = ?");
$stmt->execute([$user_id]);
$_SESSION['success'] = "User deleted successfully.";
}
} elseif ($action === 'add_book') {
// Add new book
$title = trim($_POST['title'] ?? '');
$author = trim($_POST['author'] ?? '');
$category = trim($_POST['category'] ?? '');
$total_copies = (int)($_POST['total_copies'] ?? 1);
$total_copies = max(1, $total_copies);
if ($title === '' || $author === '' || $total_copies < 1) {
$_SESSION['error'] = 'Invalid input for adding book.';
} else {
$stmt = $pdo->prepare("INSERT INTO books (title, author, category, total_copies, available_copies, created_at) VALUES (?, ?, ?, ?, ?, NOW())");
$stmt->execute([$title, $author, $category, $total_copies, $total_copies]);
$_SESSION['success'] = "Book '$title' added successfully.";
}
}
elseif ($action === 'edit_book') {
$book_id = (int)($_POST['book_id'] ?? 0);
$title = trim($_POST['title'] ?? '');
$author = trim($_POST['author'] ?? '');
$category = trim($_POST['category'] ?? '');
$total_copies = (int)($_POST['total_copies'] ?? 1);
$total_copies = max(1, $total_copies);
if ($book_id <= 0 || $title === '' || $author === '' || $total_copies < 1) {
$_SESSION['error'] = 'Invalid input for updating book.';
} else {
// Get existing book data
$stmt = $pdo->prepare("SELECT total_copies, available_copies FROM books WHERE id = ?");
$stmt->execute([$book_id]);
$book = $stmt->fetch();
if (!$book) {
$_SESSION['error'] = 'Book not found.';
} else {
// Calculate difference in total copies
$copies_diff = $total_copies - $book['total_copies'];
$new_available_copies = $book['available_copies'] + $copies_diff;
// Ensure available copies doesn't go below zero
if ($new_available_copies < 0) {
$_SESSION['error'] = 'Cannot reduce total copies below the number of currently borrowed books.';
} else {
$stmt = $pdo->prepare("UPDATE books SET title = ?, author = ?, category = ?, total_copies = ?, available_copies = ? WHERE id = ?");
$stmt->execute([$title, $author, $category, $total_copies, $new_available_copies, $book_id]);
$_SESSION['success'] = "Book '$title' updated successfully.";
}
}
}
}
elseif (isset($_POST['delete_book'])) {
// Delete book
$book_id = (int)$_POST['delete_book'];
if ($book_id > 0) {
$stmt = $pdo->prepare("DELETE FROM books WHERE id = ?");
$stmt->execute([$book_id]);
$_SESSION['success'] = "Book deleted successfully.";
} else {
$_SESSION['error'] = 'Invalid book ID.';
}
} elseif (isset($_POST['return_book'])) {
// Mark borrow record as returned
$record_id = (int)($_POST['record_id'] ?? 0);
if ($record_id > 0) {
$stmt = $pdo->prepare("SELECT br.due_date, br.book_id, br.return_date FROM borrow_records br WHERE id = ?");
$stmt->execute([$record_id]);
$record = $stmt->fetch();
if (!$record) {
$_SESSION['error'] = 'Borrow record not found.';
} elseif (!empty($record['return_date'])) {
$_SESSION['error'] = 'Book already returned.';
} else {
$due_date = new DateTime($record['due_date']);
$return_date = new DateTime();
$interval = $return_date->diff($due_date);
$fine = 0;
if ($return_date > $due_date) {
$days_late = $interval->days;
$fine = $days_late * 1; // 1$ per day late
}
$stmt = $pdo->prepare("UPDATE borrow_records SET return_date = NOW(), fine = ? WHERE id = ?");
$stmt->execute([$fine, $record_id]);
$stmt = $pdo->prepare("UPDATE books SET available_copies = available_copies + 1 WHERE id = ?");
$stmt->execute([$record['book_id']]);
$_SESSION['success'] = 'Book marked as returned.';
}
} else {
$_SESSION['error'] = 'Invalid borrow record.';
}
}
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}
}
// Stats
$totalUsers = $pdo->query("SELECT COUNT(*) FROM users")->fetchColumn();
$totalBooks = $pdo->query("SELECT COUNT(*) FROM books")->fetchColumn();
$totalBorrowed = $pdo->query("SELECT COUNT(*) FROM borrow_records WHERE return_date IS NULL")->fetchColumn();
$totalAdmins = $pdo->query("SELECT COUNT(*) FROM users WHERE role='admin'")->fetchColumn();
// Recent borrow records (limit 5)
$recentBorrows = $pdo->query("
SELECT br.id, u.username, b.title, br.borrow_date, br.due_date, br.return_date, br.fine
FROM borrow_records br
JOIN users u ON br.user_id = u.id
JOIN books b ON br.book_id = b.id
ORDER BY br.borrow_date DESC LIMIT 5
")->fetchAll();
// Fetch all borrow records
$borrow_records = $pdo->query("
SELECT br.id, u.username, b.title, br.borrow_date, br.due_date, br.return_date, br.fine
FROM borrow_records br
JOIN users u ON br.user_id = u.id
JOIN books b ON br.book_id = b.id
ORDER BY br.borrow_date DESC
")->fetchAll();
// Fetch users and books
$users = $pdo->query("SELECT id, username, role, created_at FROM users ORDER BY created_at DESC")->fetchAll();
$books = $pdo->query("SELECT * FROM books ORDER BY created_at DESC")->fetchAll();
// Logout
if (isset($_GET['action']) && $_GET['action'] === 'logout') {
session_destroy();
header('Location: login.php');
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Admin Dashboard - Library LMS</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Bootstrap 5 CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" />
<!-- Simple DataTables CSS -->
<link href="https://cdn.jsdelivr.net/npm/simple-datatables@7.1.2/dist/style.css" rel="stylesheet" />
<!-- Bootstrap Icons -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet" />
<style>
body { background: #f9fafb; }
.card-icon {
font-size: 2.4rem;
opacity: 0.3;
}
.card:hover {
box-shadow: 0 10px 20px rgb(0 0 0 / 0.12);
transition: all 0.3s ease;
}
.action-btns button {
margin-right: 5px;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container">
<a class="navbar-brand" href="#">Library LMS Admin</a>
<div class="d-flex align-items-center ms-auto">
<span class="text-white me-3">Welcome, <?=htmlspecialchars($_SESSION['username'])?></span>
<a href="?action=logout" class="btn btn-outline-light btn-sm">Logout <i class="bi bi-box-arrow-right"></i></a>
</div>
</div>
</nav>
<div class="container my-4">
<?php if (isset($_SESSION['error'])): ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<?=htmlspecialchars($_SESSION['error'])?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php unset($_SESSION['error']); ?>
<?php endif; ?>
<?php if (isset($_SESSION['success'])): ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<?=htmlspecialchars($_SESSION['success'])?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php unset($_SESSION['success']); ?>
<?php endif; ?>
<!-- Stats Cards -->
<div class="row g-4 mb-5">
<div class="col-md-3">
<div class="card shadow-sm p-3">
<div class="d-flex justify-content-between align-items-center">
<div>
<h6 class="text-uppercase text-muted">Total Users</h6>
<h3><?= $totalUsers ?></h3>
</div>
<i class="bi bi-people-fill card-icon"></i>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card shadow-sm p-3">
<div class="d-flex justify-content-between align-items-center">
<div>
<h6 class="text-uppercase text-muted">Total Books</h6>
<h3><?= $totalBooks ?></h3>
</div>
<i class="bi bi-book-fill card-icon"></i>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card shadow-sm p-3">
<div class="d-flex justify-content-between align-items-center">
<div>
<h6 class="text-uppercase text-muted">Borrowed Books</h6>
<h3><?= $totalBorrowed ?></h3>
</div>
<i class="bi bi-journal-arrow-up card-icon"></i>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card shadow-sm p-3">
<div class="d-flex justify-content-between align-items-center">
<div>
<h6 class="text-uppercase text-muted">Admins</h6>
<h3><?= $totalAdmins ?></h3>
</div>
<i class="bi bi-shield-lock-fill card-icon"></i>
</div>
</div>
</div>
</div>
<!-- Recent Borrow Records -->
<h4 class="mb-3">Recent Borrow Records</h4>
<table class="table table-striped" id="recentBorrowsTable">
<thead>
<tr>
<th>ID</th>
<th>User</th>
<th>Book</th>
<th>Borrow Date</th>
<th>Due Date</th>
<th>Return Date</th>
<th>Fine</th>
</tr>
</thead>
<tbody>
<?php foreach($recentBorrows as $r): ?>
<tr>
<td><?= $r['id'] ?></td>
<td><?= htmlspecialchars($r['username']) ?></td>
<td><?= htmlspecialchars($r['title']) ?></td>
<td><?= $r['borrow_date'] ?></td>
<td><?= $r['due_date'] ?></td>
<td><?= $r['return_date'] ?? '-' ?></td>
<td><?= $r['fine'] ? '$'.number_format($r['fine'], 2) : '-' ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<hr>
<!-- Users Management -->
<h4 class="mb-3">Users</h4>
<button class="btn btn-primary mb-3" data-bs-toggle="modal" data-bs-target="#addUserModal">
<i class="bi bi-person-plus-fill"></i> Add User
</button>
<table class="table table-hover" id="usersTable">
<thead>
<tr>
<th>ID</th>
<th>Username</th>
<th>Role</th>
<th>Created At</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($users as $u): ?>
<tr>
<td><?= $u['id'] ?></td>
<td><?= htmlspecialchars($u['username']) ?></td>
<td>
<?php if ($u['role']=='admin'): ?>
<span class="badge bg-danger">Admin</span>
<?php else: ?>
<span class="badge bg-secondary">Member</span>
<?php endif ?>
</td>
<td><?= $u['created_at'] ?></td>
<td class="action-btns">
<?php if($u['id']!=1): ?>
<form method="post" style="display:inline-block" onsubmit="return confirm('Delete user <?=htmlspecialchars(addslashes($u['username']))?>?');">
<input type="hidden" name="delete_user" value="<?= $u['id'] ?>">
<button class="btn btn-sm btn-danger"><i class="bi bi-trash-fill"></i></button>
</form>
<?php else: ?>
<span class="text-muted">Admin</span>
<?php endif ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<hr>
<!-- Books Management -->
<h4 class="mb-3">Books Inventory</h4>
<button class="btn btn-success mb-3" data-bs-toggle="modal" data-bs-target="#addBookModal">
<i class="bi bi-book-fill"></i> Add Book
</button>
<table class="table table-hover" id="booksTable">
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>Author</th>
<th>Category</th>
<th>Total Copies</th>
<th>Available Copies</th>
<th>Added On</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach($books as $b): ?>
<tr>
<td><?= $b['id'] ?></td>
<td><?= htmlspecialchars($b['title']) ?></td>
<td><?= htmlspecialchars($b['author']) ?></td>
<td><?= htmlspecialchars($b['category']) ?></td>
<td><?= $b['total_copies'] ?></td>
<td><?= $b['available_copies'] ?></td>
<td><?= $b['created_at'] ?></td>
<td class="action-btns">
<button
type="button"
class="btn btn-sm btn-warning edit-book-btn"
data-bs-toggle="modal"
data-bs-target="#editBookModal"
data-id="<?= $b['id'] ?>"
data-title="<?= htmlspecialchars($b['title'], ENT_QUOTES) ?>"
data-author="<?= htmlspecialchars($b['author'], ENT_QUOTES) ?>"
data-category="<?= htmlspecialchars($b['category'], ENT_QUOTES) ?>"
data-total-copies="<?= $b['total_copies'] ?>"
data-available-copies="<?= $b['available_copies'] ?>"
>
<i class="bi bi-pencil-fill"></i> Edit
</button>
<form method="post" style="display:inline-block" onsubmit="return confirm('Delete book <?=htmlspecialchars(addslashes($b['title']))?>?');" >
<input type="hidden" name="delete_book" value="<?= $b['id'] ?>">
<button class="btn btn-sm btn-danger"><i class="bi bi-trash-fill"></i></button>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<hr>
<!-- Borrow Records -->
<h4 class="mb-3">Borrow Records</h4>
<table class="table table-hover" id="borrowRecordsTable">
<thead>
<tr>
<th>ID</th>
<th>Username</th>
<th>Book Title</th>
<th>Borrow Date</th>
<th>Due Date</th>
<th>Return Date</th>
<th>Fine</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach($borrow_records as $br): ?>
<tr>
<td><?= $br['id'] ?></td>
<td><?= htmlspecialchars($br['username']) ?></td>
<td><?= htmlspecialchars($br['title']) ?></td>
<td><?= $br['borrow_date'] ?></td>
<td><?= $br['due_date'] ?></td>
<td><?= $br['return_date'] ?? '-' ?></td>
<td><?= $br['fine'] ? '$'.number_format($br['fine'],2) : '-' ?></td>
<td class="action-btns">
<?php if(empty($br['return_date'])): ?>
<form method="post" onsubmit="return confirm('Mark this book as returned?');" style="display:inline-block;">
<input type="hidden" name="record_id" value="<?= $br['id'] ?>">
<button name="return_book" class="btn btn-sm btn-primary"><i class="bi bi-arrow-return-left"></i> Return</button>
</form>
<?php else: ?>
<span class="badge bg-success">Returned</span>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<!-- Modals -->
<!-- Add User Modal -->
<div class="modal fade" id="addUserModal" tabindex="-1" aria-labelledby="addUserModalLabel" aria-hidden="true">
<div class="modal-dialog">
<form method="post" class="modal-content needs-validation" novalidate>
<input type="hidden" name="action" value="add_user" />
<div class="modal-header">
<h5 class="modal-title" id="addUserModalLabel">Add New User</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label for="add-username" class="form-label">Username *</label>
<input type="text" class="form-control" id="add-username" name="username" required />
<div class="invalid-feedback">Please enter a username.</div>
</div>
<div class="mb-3">
<label for="add-password" class="form-label">Password *</label>
<input type="password" class="form-control" id="add-password" name="password" required />
<div class="invalid-feedback">Please enter a password.</div>
</div>
<div class="mb-3">
<label for="add-role" class="form-label">Role *</label>
<select name="role" id="add-role" class="form-select" required>
<option value="member" selected>Member</option>
<option value="admin">Admin</option>
</select>
<div class="invalid-feedback">Please select a role.</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Add User</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
<!-- Add Book Modal -->
<div class="modal fade" id="addBookModal" tabindex="-1" aria-labelledby="addBookModalLabel" aria-hidden="true">
<div class="modal-dialog">
<form method="post" class="modal-content needs-validation" novalidate>
<input type="hidden" name="action" value="add_book"/>
<div class="modal-header">
<h5 class="modal-title" id="addBookModalLabel">Add New Book</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label for="add-title" class="form-label">Title *</label>
<input type="text" class="form-control" id="add-title" name="title" required />
<div class="invalid-feedback">Please enter a title.</div>
</div>
<div class="mb-3">
<label for="add-author" class="form-label">Author *</label>
<input type="text" class="form-control" id="add-author" name="author" required />
<div class="invalid-feedback">Please enter the author.</div>
</div>
<div class="mb-3">
<label for="add-category" class="form-label">Category</label>
<input type="text" class="form-control" id="add-category" name="category" />
</div>
<div class="mb-3">
<label for="add-total_copies" class="form-label">Total Copies *</label>
<input type="number" min="1" class="form-control" id="add-total_copies" name="total_copies" required value="1" />
<div class="invalid-feedback">Please enter total copies (>=1).</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-success">Add Book</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
<!-- Edit Book Modal -->
<div class="modal fade" id="editBookModal" tabindex="-1" aria-labelledby="editBookModalLabel" aria-hidden="true">
<div class="modal-dialog">
<form method="post" class="modal-content needs-validation" novalidate>
<input type="hidden" name="action" value="edit_book"/>
<input type="hidden" name="book_id" id="edit-book-id" />
<div class="modal-header">
<h5 class="modal-title" id="editBookModalLabel">Edit Book</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label for="edit-title" class="form-label">Title *</label>
<input type="text" class="form-control" id="edit-title" name="title" required />
<div class="invalid-feedback">Please enter a title.</div>
</div>
<div class="mb-3">
<label for="edit-author" class="form-label">Author *</label>
<input type="text" class="form-control" id="edit-author" name="author" required />
<div class="invalid-feedback">Please enter the author.</div>
</div>
<div class="mb-3">
<label for="edit-category" class="form-label">Category</label>
<input type="text" class="form-control" id="edit-category" name="category" />
</div>
<div class="mb-3">
<label for="edit-total_copies" class="form-label">Total Copies *</label>
<input type="number" min="1" class="form-control" id="edit-total_copies" name="total_copies" required />
<div class="invalid-feedback">Please enter total copies (>=1).</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-warning">Update Book</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@7.1.2/dist/simple-datatables.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
// Initialize datatables
new simpleDatatables.DataTable("#usersTable");
new simpleDatatables.DataTable("#booksTable");
new simpleDatatables.DataTable("#borrowRecordsTable");
new simpleDatatables.DataTable("#recentBorrowsTable");
// Populate Edit Book Modal
document.querySelectorAll('.edit-book-btn').forEach(button => {
button.addEventListener('click', () => {
const modal = document.getElementById('editBookModal');
modal.querySelector('#edit-book-id').value = button.getAttribute('data-id');
modal.querySelector('#edit-title').value = button.getAttribute('data-title');
modal.querySelector('#edit-author').value = button.getAttribute('data-author');
modal.querySelector('#edit-category').value = button.getAttribute('data-category');
modal.querySelector('#edit-total_copies').value = button.getAttribute('data-total-copies');
});
});
// Bootstrap form validation
(() => {
'use strict'
const forms = document.querySelectorAll('.needs-validation');
Array.from(forms).forEach(form => {
form.addEventListener('submit', evt => {
if (!form.checkValidity()) {
evt.preventDefault();
evt.stopPropagation();
}
form.classList.add('was-validated');
});
});
})();
});
</script>
</body>
</html>
What’s new/updated:
Edit button in Books table next to Delete.
Edit Book Modal that pre-fills book info.
PHP handling of the edit_book action, with validation and careful updates to the available_copies.
Javascript that loads data into the edit modal on button click.
Let me know if you want me to help you add more features like editing users, changing roles, password reset, or anything else!
Add these CSS styles into your <style> block (inside <head> or preferably in your CSS file): css Copy code
.login-wrapper {
min-height: 100vh;
padding: 20px;
max-width: 900px;
margin: 0 auto;
}
.login-image-wrapper {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
max-width: 450px;
}
.login-image {
width: 100%;
height: auto;
border-radius: 15px;
box-shadow: 0 15px 40px rgba(0,0,0,0.3);
}
.login-container {
flex: 1;
max-width: 420px;
background: rgba(255, 255, 255, 0.1);
padding: 40px 50px;
border-radius: 15px;
box-shadow: 0 15px 40px rgba(0,0,0,0.3);
backdrop-filter: blur(10px);
animation: fadeIn 1s ease forwards;
}
/* Adjust layout for small devices */
@media (max-width: 767px) {
.login-wrapper {
flex-direction: column;
}
.login-image-wrapper {
max-width: 100%;
margin-bottom: 30px;
}
.login-image {
border-radius: 15px;
max-height: 250px;
object-fit: cover;
}
}
What this does:
On desktop/tablet widths, the image sits side by side to the login form.
On smaller screens, the image is stacked above the form.
The image is nicely styled with rounded corners and shadows matching the form.
You keep all your login styles, and the image just decorates the page.
Full example (just the <body> part, since the rest stays the same): html Copy code
<body>
<div class="login-wrapper d-flex flex-column flex-md-row align-items-center justify-content-center gap-4">
<!-- Image Section -->
<div class="login-image-wrapper">
<img src="https://images.unsplash.com/photo-1524995997946-a1c2e315a42f?auto=format&fit=crop&w=800&q=80" alt="Library" class="login-image" />
</div>
<!-- Login Form Section -->
<div class="login-container shadow-lg">
<h2>User Login</h2>
<?php if ($error): ?>
<div class="alert alert-danger"><?=htmlspecialchars($error)?></div>
<?php endif; ?>
<form method="post" novalidate autocomplete="off">
<div class="mb-4">
<label for="username" class="form-label">Username</label>
<input id="username" type="text" name="username" class="form-control" placeholder="Enter your username" required value="<?=htmlspecialchars($_POST['username'] ?? '')?>" />
</div>
<div class="mb-5">
<label for="password" class="form-label">Password</label>
<input id="password" type="password" name="password" class="form-control" placeholder="Enter your password" required />
</div>
<button type="submit" class="btn btn-primary">Log In</button>
</form>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
Let me know if you want me to provide the full updated full login page code including this!
<?php
session_start();
require 'config.php';
$error = '';
// If user already logged in, send to correct dashboard
if (isset($_SESSION['username']) && isset($_SESSION['role'])) {
if ($_SESSION['role'] === 'admin') {
header("Location: admin_dashboard.php");
} else {
header("Location: member_dashboard.php");
}
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = trim($_POST['username'] ?? '');
$password = $_POST['password'] ?? '';
if ($username === '' || $password === '') {
$error = "Please fill both username and password.";
} else {
// Check user in DB
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?");
$stmt->execute([$username]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
// Save user info in session
$_SESSION['username'] = $user['username'];
$_SESSION['user_id'] = $user['id'];
$_SESSION['role'] = $user['role'];
// Redirect depending on role
if ($user['role'] === 'admin') {
header("Location: admin_dashboard.php");
} else {
header("Location: member_dashboard.php");
}
exit;
} else {
$error = "Invalid username or password.";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Library LMS - Login</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" />
<!-- Optional Google Font -->
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet" />
<style>
body, html {
height: 100%;
background: linear-gradient(135deg, #667eea, #764ba2);
font-family: 'Poppins', sans-serif;
color: #fff;
margin: 0;
padding: 20px;
}
/* Wrapper for image + form */
.login-wrapper {
min-height: 100vh;
max-width: 900px;
margin: 0 auto;
display: flex;
flex-direction: column;
gap: 30px;
justify-content: center;
align-items: center;
}
@media(min-width: 768px) {
.login-wrapper {
flex-direction: row;
gap: 60px;
}
}
/* Image wrapper */
.login-image-wrapper {
flex: 1;
max-width: 450px;
display: flex;
justify-content: center;
align-items: center;
}
.login-image {
width: 100%;
height: auto;
border-radius: 15px;
box-shadow: 0 15px 40px rgba(0,0,0,0.3);
object-fit: cover;
}
/* Form container */
.login-container {
flex: 1;
max-width: 420px;
background: rgba(255, 255, 255, 0.1);
padding: 40px 50px;
border-radius: 15px;
box-shadow: 0 15px 40px rgba(0,0,0,0.3);
backdrop-filter: blur(10px);
animation: fadeIn 1s ease forwards;
width: 100%;
}
h2 {
font-weight: 600;
margin-bottom: 30px;
text-align: center;
letter-spacing: 1.5px;
text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
label {
font-weight: 600;
letter-spacing: 0.8px;
color: #e0e0e0;
}
.form-control {
background: rgba(255,255,255,0.2);
border: none;
border-radius: 10px;
color: #fff;
padding: 15px 20px;
font-size: 1rem;
box-shadow: inset 2px 2px 4px rgba(255,255,255,0.3);
transition: background-color 0.3s ease;
}
.form-control:focus {
background: rgba(255,255,255,0.4);
color: #222;
box-shadow: 0 0 10px #9155fd;
outline: none;
}
.btn-primary {
background: #9155fd;
border: none;
padding: 15px 0;
font-weight: 600;
font-size: 1.1rem;
border-radius: 10px;
width: 100%;
transition: background-color 0.3s ease;
box-shadow: 0 5px 15px rgba(145,85,253,0.6);
}
.btn-primary:hover {
background: #682bdf;
box-shadow: 0 8px 25px rgba(104,43,223,0.7);
}
.alert-danger {
background-color: rgba(255, 72, 66, 0.85);
border-radius: 8px;
padding: 12px 20px;
font-weight: 600;
margin-bottom: 20px;
text-align: center;
box-shadow: 0 3px 10px rgba(255,72,66,0.5);
}
@keyframes fadeIn {
0% {opacity: 0; transform: translateY(20px);}
100% {opacity: 1; transform: translateY(0);}
}
::placeholder {
color: rgba(255,255,255,0.7);
font-weight: 400;
}
</style>
</head>
<body>
<div class="login-wrapper">
<!-- Image Section -->
<div class="login-image-wrapper">
<img src="https://images.unsplash.com/photo-1524995997946-a1c2e315a42f?auto=format&fit=crop&w=800&q=80" alt="Library" class="login-image" />
</div>
<!-- Login Form Section -->
<div class="login-container shadow-lg">
<h2>User Login</h2>
<?php if ($error): ?>
<div class="alert alert-danger"><?=htmlspecialchars($error)?></div>
<?php endif; ?>
<form method="post" novalidate autocomplete="off">
<div class="mb-4">
<label for="username" class="form-label">Username</label>
<input id="username" type="text" name="username" class="form-control" placeholder="Enter your username" required value="<?=htmlspecialchars($_POST['username'] ?? '')?>" />
</div>
<div class="mb-5">
<label for="password" class="form-label">Password</label>
<input id="password" type="password" name="password" class="form-control" placeholder="Enter your password" required />
</div>
<button type="submit" class="btn btn-primary">Log In</button>
</form>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
What it does:
Shows a nice library image on the left (or top on small screens).
The login form on the right (or below on small screens).
Responsive and visually appealing with smooth animations and shadows.
Keeps your existing form validation/error handling intact.
Feel free to replace the image URL with any other library-related image you prefer!
If you want me to add a local image or any other specific design changes, just ask!
code Copy code
<!-- Image Section -->
<div class="login-image-wrapper">
<img src="https://images.unsplash.com/photo-1524995997946-a1c2e315a42f?auto=format&fit=crop&w=800&q=80" alt="Library" class="login-image" />
</div>
<!-- Login Form Section -->
<div class="login-container shadow-lg">
<h2>User Login</h2>
<?php if ($error): ?>
<div class="alert alert-danger"><?=htmlspecialchars($error)?></div>
<?php endif; ?>
<form method="post" novalidate autocomplete="off">
<div class="mb-4">
<label for="username" class="form-label">Username</label>
<input id="username" type="text" name="username" class="form-control" placeholder="Enter your username" required value="<?=htmlspecialchars($_POST['username'] ?? '')?>" />
</div>
<div class="mb-5">
<label for="password" class="form-label">Password</label>
<input id="password" type="password" name="password" class="form-control" placeholder="Enter your password" required />
</div>
<button type="submit" class="btn btn-primary">Log In</button>
</form>
</div>
<?php
session_start();
require 'config.php';
$error = '';
// If user already logged in, send to correct dashboard
if (isset($_SESSION['username']) && isset($_SESSION['role'])) {
if ($_SESSION['role'] === 'admin') {
header("Location: admin_dashboard.php");
} else {
header("Location: member_dashboard.php");
}
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = trim($_POST['username'] ?? '');
$password = $_POST['password'] ?? '';
if ($username === '' || $password === '') {
$error = "Please fill both username and password.";
} else {
// Check user in DB
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?");
$stmt->execute([$username]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
// Save user info in session
$_SESSION['username'] = $user['username'];
$_SESSION['user_id'] = $user['id'];
$_SESSION['role'] = $user['role'];
// Redirect depending on role
if ($user['role'] === 'admin') {
header("Location: admin_dashboard.php");
} else {
header("Location: member_dashboard.php");
}
exit;
} else {
$error = "Invalid username or password.";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Library LMS - Login</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" />
<!-- Optional Google Font -->
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet" />
<style>
body, html {
height: 100%;
background: linear-gradient(135deg, #667eea, #764ba2);
font-family: 'Poppins', sans-serif;
color: #fff;
margin: 0;
padding: 20px;
}
/* Wrapper for image + form */
.login-wrapper {
min-height: 100vh;
max-width: 900px;
margin: 0 auto;
display: flex;
flex-direction: column;
gap: 30px;
justify-content: center;
align-items: center;
}
@media(min-width: 768px) {
.login-wrapper {
flex-direction: row;
gap: 60px;
}
}
/* Image wrapper */
.login-image-wrapper {
flex: 1;
max-width: 450px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.login-image-wrapper h1 {
margin-bottom: 24px;
font-weight: 700;
font-size: 2.3rem;
color: #fff;
text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.login-image {
width: 100%;
height: auto;
border-radius: 15px;
box-shadow: 0 15px 40px rgba(0,0,0,0.3);
object-fit: cover;
}
/* Form container */
.login-container {
flex: 1;
max-width: 420px;
background: rgba(255, 255, 255, 0.1);
padding: 40px 50px;
border-radius: 15px;
box-shadow: 0 15px 40px rgba(0,0,0,0.3);
backdrop-filter: blur(10px);
animation: fadeIn 1s ease forwards;
width: 100%;
}
h2 {
font-weight: 600;
margin-bottom: 30px;
text-align: center;
letter-spacing: 1.5px;
text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
label {
font-weight: 600;
letter-spacing: 0.8px;
color: #e0e0e0;
}
.form-control {
background: rgba(255,255,255,0.2);
border: none;
border-radius: 10px;
color: #fff;
padding: 15px 20px;
font-size: 1rem;
box-shadow: inset 2px 2px 4px rgba(255,255,255,0.3);
transition: background-color 0.3s ease;
}
.form-control:focus {
background: rgba(255,255,255,0.4);
color: #222;
box-shadow: 0 0 10px #9155fd;
outline: none;
}
.btn-primary {
background: #9155fd;
border: none;
padding: 15px 0;
font-weight: 600;
font-size: 1.1rem;
border-radius: 10px;
width: 100%;
transition: background-color 0.3s ease;
box-shadow: 0 5px 15px rgba(145,85,253,0.6);
}
.btn-primary:hover {
background: #682bdf;
box-shadow: 0 8px 25px rgba(104,43,223,0.7);
}
.alert-danger {
background-color: rgba(255, 72, 66, 0.85);
border-radius: 8px;
padding: 12px 20px;
font-weight: 600;
margin-bottom: 20px;
text-align: center;
box-shadow: 0 3px 10px rgba(255,72,66,0.5);
}
@keyframes fadeIn {
0% {opacity: 0; transform: translateY(20px);}
100% {opacity: 1; transform: translateY(0);}
}
::placeholder {
color: rgba(255,255,255,0.7);
font-weight: 400;
}
</style>
</head>
<body>
<div class="login-wrapper">
<!-- Image Section -->
<div class="login-image-wrapper">
<h1>Library Management System</h1>
<img src="https://images.unsplash.com/photo-1524995997946-a1c2e315a42f?auto=format&fit=crop&w=800&q=80" alt="Library" class="login-image" />
</div>
<!-- Login Form Section -->
<div class="login-container shadow-lg">
<h2>User Login</h2>
<?php if ($error): ?>
<div class="alert alert-danger"><?=htmlspecialchars($error)?></div>
<?php endif; ?>
<form method="post" novalidate autocomplete="off">
<div class="mb-4">
<label for="username" class="form-label">Username</label>
<input id="username" type="text" name="username" class="form-control" placeholder="Enter your username" required value="<?=htmlspecialchars($_POST['username'] ?? '')?>" />
</div>
<div class="mb-5">
<label for="password" class="form-label">Password</label>
<input id="password" type="password" name="password" class="form-control" placeholder="Enter your password" required />
</div>
<button type="submit" class="btn btn-primary">Log In</button>
</form>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
What’s new:
Added <h1>Library Management System</h1> above the library image with suitable styling.
The heading is centered and has a subtle text shadow for better readability on the gradient background.
Feel free to customize heading text, size, or color as you like! Let me know if you need any other help!
.login-image-wrapper h1 {
margin-bottom: 24px;
font-weight: 800;
font-size: 2.8rem;
text-align: center;
background: linear-gradient(45deg, #6a11cb, #2575fc);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
-webkit-text-fill-color: transparent;
letter-spacing: 2px;
text-shadow: 0 0 8px rgba(101, 81, 224, 0.6);
animation: glowText 2s ease-in-out infinite alternate;
}
@keyframes glowText {
0% {
text-shadow:
0 0 8px rgba(101, 81, 224, 0.6),
0 0 20px rgba(101, 81, 224, 0.5),
0 0 30px rgba(101, 81, 224, 0.4);
}
100% {
text-shadow:
0 0 12px rgba(101, 81, 224, 0.9),
0 0 28px rgba(101, 81, 224, 0.7),
0 0 40px rgba(101, 81, 224, 0.6);
}
}
If you want, I can provide the entire updated full login page code with this style included. Would you like that?
<?php
session_start();
require 'config.php';
$error = '';
// If user already logged in, send to correct dashboard
if (isset($_SESSION['username']) && isset($_SESSION['role'])) {
if ($_SESSION['role'] === 'admin') {
header("Location: admin_dashboard.php");
} else {
header("Location: member_dashboard.php");
}
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = trim($_POST['username'] ?? '');
$password = $_POST['password'] ?? '';
if ($username === '' || $password === '') {
$error = "Please fill both username and password.";
} else {
// Check user in DB
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?");
$stmt->execute([$username]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
// Save user info in session
$_SESSION['username'] = $user['username'];
$_SESSION['user_id'] = $user['id'];
$_SESSION['role'] = $user['role'];
// Redirect depending on role
if ($user['role'] === 'admin') {
header("Location: admin_dashboard.php");
} else {
header("Location: member_dashboard.php");
}
exit;
} else {
$error = "Invalid username or password.";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Library LMS - Login</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" />
<!-- Optional Google Font -->
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet" />
<style>
body, html {
height: 100%;
background: linear-gradient(135deg, #667eea, #764ba2);
font-family: 'Poppins', sans-serif;
color: #fff;
margin: 0;
padding: 20px;
}
/* Wrapper for image + form */
.login-wrapper {
min-height: 100vh;
max-width: 900px;
margin: 0 auto;
display: flex;
flex-direction: column;
gap: 30px;
justify-content: center;
align-items: center;
}
@media(min-width: 768px) {
.login-wrapper {
flex-direction: row;
gap: 60px;
}
}
/* Image wrapper */
.login-image-wrapper {
flex: 1;
max-width: 450px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.login-image-wrapper h1 {
margin-bottom: 24px;
font-weight: 800;
font-size: 2.8rem;
text-align: center;
background: linear-gradient(45deg, #6a11cb, #2575fc);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
-webkit-text-fill-color: transparent;
letter-spacing: 2px;
text-shadow: 0 0 8px rgba(101, 81, 224, 0.6);
animation: glowText 2s ease-in-out infinite alternate;
}
@keyframes glowText {
0% {
text-shadow:
0 0 8px rgba(101, 81, 224, 0.6),
0 0 20px rgba(101, 81, 224, 0.5),
0 0 30px rgba(101, 81, 224, 0.4);
}
100% {
text-shadow:
0 0 12px rgba(101, 81, 224, 0.9),
0 0 28px rgba(101, 81, 224, 0.7),
0 0 40px rgba(101, 81, 224, 0.6);
}
}
.login-image {
width: 100%;
height: auto;
border-radius: 15px;
box-shadow: 0 15px 40px rgba(0,0,0,0.3);
object-fit: cover;
}
/* Form container */
.login-container {
flex: 1;
max-width: 420px;
background: rgba(255, 255, 255, 0.1);
padding: 40px 50px;
border-radius: 15px;
box-shadow: 0 15px 40px rgba(0,0,0,0.3);
backdrop-filter: blur(10px);
animation: fadeIn 1s ease forwards;
width: 100%;
}
h2 {
font-weight: 600;
margin-bottom: 30px;
text-align: center;
letter-spacing: 1.5px;
text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
label {
font-weight: 600;
letter-spacing: 0.8px;
color: #e0e0e0;
}
.form-control {
background: rgba(255,255,255,0.2);
border: none;
border-radius: 10px;
color: #fff;
padding: 15px 20px;
font-size: 1rem;
box-shadow: inset 2px 2px 4px rgba(255,255,255,0.3);
transition: background-color 0.3s ease;
}
.form-control:focus {
background: rgba(255,255,255,0.4);
color: #222;
box-shadow: 0 0 10px #9155fd;
outline: none;
}
.btn-primary {
background: #9155fd;
border: none;
padding: 15px 0;
font-weight: 600;
font-size: 1.1rem;
border-radius: 10px;
width: 100%;
transition: background-color 0.3s ease;
box-shadow: 0 5px 15px rgba(145,85,253,0.6);
}
.btn-primary:hover {
background: #682bdf;
box-shadow: 0 8px 25px rgba(104,43,223,0.7);
}
.alert-danger {
background-color: rgba(255, 72, 66, 0.85);
border-radius: 8px;
padding: 12px 20px;
font-weight: 600;
margin-bottom: 20px;
text-align: center;
box-shadow: 0 3px 10px rgba(255,72,66,0.5);
}
@keyframes fadeIn {
0% {opacity: 0; transform: translateY(20px);}
100% {opacity: 1; transform: translateY(0);}
}
::placeholder {
color: rgba(255,255,255,0.7);
font-weight: 400;
}
</style>
</head>
<body>
<div class="login-wrapper">
<!-- Image Section -->
<div class="login-image-wrapper">
<h1>Library Management System</h1>
<img src="https://images.unsplash.com/photo-1524995997946-a1c2e315a42f?auto=format&fit=crop&w=800&q=80" alt="Library" class="login-image" />
</div>
<!-- Login Form Section -->
<div class="login-container shadow-lg">
<h2>User Login</h2>
<?php if ($error): ?>
<div class="alert alert-danger"><?=htmlspecialchars($error)?></div>
<?php endif; ?>
<form method="post" novalidate autocomplete="off">
<div class="mb-4">
<label for="username" class="form-label">Username</label>
<input id="username" type="text" name="username" class="form-control" placeholder="Enter your username" required value="<?=htmlspecialchars($_POST['username'] ?? '')?>" />
</div>
<div class="mb-5">
<label for="password" class="form-label">Password</label>
<input id="password" type="password" name="password" class="form-control" placeholder="Enter your password" required />
</div>
<button type="submit" class="btn btn-primary">Log In</button>
</form>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
What’s new:
The heading "Library Management System" uses a purple-blue gradient fill with a glowing text shadow.
The glow pulsates using a CSS animation for a modern and appealing effect.
If you want me to customize or tweak colors, animation speed, or font sizes, just ask!
<?php
session_start();
require 'config.php';
$error = '';
// If user already logged in, send to correct dashboard
if (isset($_SESSION['username']) && isset($_SESSION['role'])) {
if ($_SESSION['role'] === 'admin') {
header("Location: admin_dashboard.php");
} else {
header("Location: member_dashboard.php");
}
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = trim($_POST['username'] ?? '');
$password = $_POST['password'] ?? '';
if ($username === '' || $password === '') {
$error = "Please fill both username and password.";
} else {
// Check user in DB
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?");
$stmt->execute([$username]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
// Save user info in session
$_SESSION['username'] = $user['username'];
$_SESSION['user_id'] = $user['id'];
$_SESSION['role'] = $user['role'];
// Redirect depending on role
if ($user['role'] === 'admin') {
header("Location: admin_dashboard.php");
} else {
header("Location: member_dashboard.php");
}
exit;
} else {
$error = "Invalid username or password.";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Library LMS - Login</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" />
<!-- Optional Google Font -->
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet" />
<style>
body, html {
height: 100%;
background: linear-gradient(135deg, #667eea, #764ba2);
font-family: 'Poppins', sans-serif;
color: #fff;
margin: 0;
padding: 20px;
}
/* Wrapper for image + form */
.login-wrapper {
min-height: 100vh;
max-width: 900px;
margin: 0 auto;
display: flex;
flex-direction: column;
gap: 30px;
justify-content: center;
align-items: center;
}
@media(min-width: 768px) {
.login-wrapper {
flex-direction: row;
gap: 60px;
}
}
/* Image wrapper */
.login-image-wrapper {
flex: 1;
max-width: 450px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.login-image-wrapper h1 {
margin-bottom: 24px;
font-weight: 800;
font-size: 2.8rem;
text-align: center;
color: #fff;
letter-spacing: 2px;
text-shadow:
0 0 8px rgba(255, 255, 255, 0.8),
0 0 20px rgba(255, 255, 255, 0.6),
0 0 30px rgba(255, 255, 255, 0.5);
background-color: rgba(0, 0, 0, 0.25);
padding: 10px 20px;
border-radius: 12px;
box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}
.login-image {
width: 100%;
height: auto;
border-radius: 15px;
box-shadow: 0 15px 40px rgba(0,0,0,0.3);
object-fit: cover;
}
/* Form container */
.login-container {
flex: 1;
max-width: 420px;
background: rgba(255, 255, 255, 0.1);
padding: 40px 50px;
border-radius: 15px;
box-shadow: 0 15px 40px rgba(0,0,0,0.3);
backdrop-filter: blur(10px);
animation: fadeIn 1s ease forwards;
width: 100%;
}
h2 {
font-weight: 600;
margin-bottom: 30px;
text-align: center;
letter-spacing: 1.5px;
text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
label {
font-weight: 600;
letter-spacing: 0.8px;
color: #e0e0e0;
}
.form-control {
background: rgba(255,255,255,0.2);
border: none;
border-radius: 10px;
color: #fff;
padding: 15px 20px;
font-size: 1rem;
box-shadow: inset 2px 2px 4px rgba(255,255,255,0.3);
transition: background-color 0.3s ease;
}
.form-control:focus {
background: rgba(255,255,255,0.4);
color: #222;
box-shadow: 0 0 10px #9155fd;
outline: none;
}
.btn-primary {
background: #9155fd;
border: none;
padding: 15px 0;
font-weight: 600;
font-size: 1.1rem;
border-radius: 10px;
width: 100%;
transition: background-color 0.3s ease;
box-shadow: 0 5px 15px rgba(145,85,253,0.6);
}
.btn-primary:hover {
background: #682bdf;
box-shadow: 0 8px 25px rgba(104,43,223,0.7);
}
.alert-danger {
background-color: rgba(255, 72, 66, 0.85);
border-radius: 8px;
padding: 12px 20px;
font-weight: 600;
margin-bottom: 20px;
text-align: center;
box-shadow: 0 3px 10px rgba(255,72,66,0.5);
}
@keyframes fadeIn {
0% {opacity: 0; transform: translateY(20px);}
100% {opacity: 1; transform: translateY(0);}
}
::placeholder {
color: rgba(255,255,255,0.7);
font-weight: 400;
}
</style>
</head>
<body>
<div class="login-wrapper">
<!-- Image Section -->
<div class="login-image-wrapper">
<h1>Library Management System</h1>
<img src="https://images.unsplash.com/photo-1524995997946-a1c2e315a42f?auto=format&fit=crop&w=800&q=80" alt="Library" class="login-image" />
</div>
<!-- Login Form Section -->
<div class="login-container shadow-lg">
<h2>User Login</h2>
<?php if ($error): ?>
<div class="alert alert-danger"><?=htmlspecialchars($error)?></div>
<?php endif; ?>
<form method="post" novalidate autocomplete="off">
<div class="mb-4">
<label for="username" class="form-label">Username</label>
<input id="username" type="text" name="username" class="form-control" placeholder="Enter your username" required value="<?=htmlspecialchars($_POST['username'] ?? '')?>" />
</div>
<div class="mb-5">
<label for="password" class="form-label">Password</label>
<input id="password" type="password" name="password" class="form-control" placeholder="Enter your password" required />
</div>
<button type="submit" class="btn btn-primary">Log In</button>
</form>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
Let me know if you'd like it styled differently or if you want me to help with anything else!
/* Wrapper for image + form */
.login-wrapper {
min-height: 100vh;
max-width: 900px;
margin: 0 auto;
display: flex;
flex-direction: column;
gap: 30px;
justify-content: center;
align-items: center;
}
@media(min-width: 768px) {
.login-wrapper {
flex-direction: row;
gap: 60px;
}
}
/* Image wrapper */
.login-image-wrapper {
flex: 1;
max-width: 450px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.login-image-wrapper h1 {
margin-bottom: 24px;
font-weight: 800;
font-size: 2.8rem;
text-align: center;
color: #fff;
letter-spacing: 2px;
text-shadow:
0 0 8px rgba(255, 255, 255, 0.8),
0 0 20px rgba(255, 255, 255, 0.6),
0 0 30px rgba(255, 255, 255, 0.5);
background-color: rgba(0, 0, 0, 0.25);
padding: 10px 20px;
border-radius: 12px;
box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}
.login-image {
width: 100%;
height: auto;
border-radius: 15px;
box-shadow: 0 15px 40px rgba(0,0,0,0.3);
object-fit: cover;
}
/* Form container */
.login-container {
flex: 1;
max-width: 420px;
background: rgba(255, 255, 255, 0.1);
padding: 40px 50px;
border-radius: 15px;
box-shadow: 0 15px 40px rgba(0,0,0,0.3);
backdrop-filter: blur(10px);
animation: fadeIn 1s ease forwards;
width: 100%;
}
h2 {
font-weight: 600;
margin-bottom: 30px;
text-align: center;
letter-spacing: 1.5px;
text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
label {
font-weight: 600;
letter-spacing: 0.8px;
color: #e0e0e0;
}
.form-control {
background: rgba(255,255,255,0.2);
border: none;
border-radius: 10px;
color: #fff;
padding: 15px 20px;
font-size: 1rem;
box-shadow: inset 2px 2px 4px rgba(255,255,255,0.3);
transition: background-color 0.3s ease;
}
.form-control:focus {
background: rgba(255,255,255,0.4);
color: #222;
box-shadow: 0 0 10px #9155fd;
outline: none;
}
.btn-primary {
background: #9155fd;
border: none;
padding: 15px 0;
font-weight: 600;
font-size: 1.1rem;
border-radius: 10px;
width: 100%;
transition: background-color 0.3s ease;
box-shadow: 0 5px 15px rgba(145,85,253,0.6);
}
.btn-primary:hover {
background: #682bdf;
box-shadow: 0 8px 25px rgba(104,43,223,0.7);
}
.alert-danger {
background-color: rgba(255, 72, 66, 0.85);
border-radius: 8px;
padding: 12px 20px;
font-weight: 600;
margin-bottom: 20px;
text-align: center;
box-shadow: 0 3px 10px rgba(255,72,66,0.5);
}
@keyframes fadeIn {
0% {opacity: 0; transform: translateY(20px);}
100% {opacity: 1; transform: translateY(0);}
}
::placeholder {
color: rgba(255,255,255,0.7);
font-weight: 400;
}
</style>
code Copy code
<!-- Image Section -->
<div class="login-image-wrapper">
<h1>Library Management System</h1>
<img src="https://images.unsplash.com/photo-1524995997946-a1c2e315a42f?auto=format&fit=crop&w=800&q=80" alt="Library" class="login-image" />
</div>
<!-- Login Form Section -->
<div class="login-container shadow-lg">
<h2>User Login</h2>
<?php if ($error): ?>
<div class="alert alert-danger"><?=htmlspecialchars($error)?></div>
<?php endif; ?>
<form method="post" novalidate autocomplete="off">
<div class="mb-4">
<label for="username" class="form-label">Username</label>
<input id="username" type="text" name="username" class="form-control" placeholder="Enter your username" required value="<?=htmlspecialchars($_POST['username'] ?? '')?>" />
</div>
<div class="mb-5">
<label for="password" class="form-label">Password</label>
<input id="password" type="password" name="password" class="form-control" placeholder="Enter your password" required />
</div>
<button type="submit" class="btn btn-primary">Log In</button>
</form>
</div>
<?php
session_start();
require 'config.php';
$error = '';
// If user already logged in, send to correct dashboard
if (isset($_SESSION['username']) && isset($_SESSION['role'])) {
if ($_SESSION['role'] === 'admin') {
header("Location: admin_dashboard.php");
} else {
header("Location: member_dashboard.php");
}
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = trim($_POST['username'] ?? '');
$password = $_POST['password'] ?? '';
if ($username === '' || $password === '') {
$error = "Please fill both username and password.";
} else {
// Check user in DB
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?");
$stmt->execute([$username]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
// Save user info in session
$_SESSION['username'] = $user['username'];
$_SESSION['user_id'] = $user['id'];
$_SESSION['role'] = $user['role'];
// Redirect depending on role
if ($user['role'] === 'admin') {
header("Location: admin_dashboard.php");
} else {
header("Location: member_dashboard.php");
}
exit;
} else {
$error = "Invalid username or password.";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Library LMS - Login</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" />
<!-- Optional Google Font -->
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet" />
<style>
body, html {
height: 100%;
background: linear-gradient(135deg, #667eea, #764ba2);
font-family: 'Poppins', sans-serif;
color: #fff;
margin: 0;
padding: 20px;
}
/* Wrapper for image + form */
.login-wrapper {
min-height: 100vh;
max-width: 900px;
margin: 0 auto;
display: flex;
flex-direction: column;
gap: 30px;
justify-content: center;
align-items: center;
}
@media(min-width: 768px) {
.login-wrapper {
flex-direction: row;
gap: 60px;
}
}
/* Image wrapper */
.login-image-wrapper {
flex: 1;
max-width: 450px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.login-image-wrapper h1 {
margin-bottom: 24px;
font-weight: 800;
font-size: 2.8rem;
text-align: center;
color: #fff;
letter-spacing: 2px;
text-shadow:
0 0 8px rgba(255, 255, 255, 0.8),
0 0 20px rgba(255, 255, 255, 0.6),
0 0 30px rgba(255, 255, 255, 0.5);
background-color: rgba(0, 0, 0, 0.25);
padding: 10px 20px;
border-radius: 12px;
box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}
.login-image {
width: 100%;
height: auto;
border-radius: 15px;
box-shadow: 0 15px 40px rgba(0,0,0,0.3);
object-fit: cover;
}
/* Form container */
.login-container {
flex: 1;
max-width: 420px;
background: rgba(255, 255, 255, 0.1);
padding: 40px 50px;
border-radius: 15px;
box-shadow: 0 15px 40px rgba(0,0,0,0.3);
backdrop-filter: blur(10px);
animation: fadeIn 1s ease forwards;
width: 100%;
}
h2 {
font-weight: 600;
margin-bottom: 30px;
text-align: center;
letter-spacing: 1.5px;
text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
label {
font-weight: 600;
letter-spacing: 0.8px;
color: #e0e0e0;
}
.form-control {
background: rgba(255,255,255,0.2);
border: none;
border-radius: 10px;
color: #fff;
padding: 15px 20px;
font-size: 1rem;
box-shadow: inset 2px 2px 4px rgba(255,255,255,0.3);
transition: background-color 0.3s ease;
}
.form-control:focus {
background: rgba(255,255,255,0.4);
color: #222;
box-shadow: 0 0 10px #9155fd;
outline: none;
}
.btn-primary {
background: #9155fd;
border: none;
padding: 15px 0;
font-weight: 600;
font-size: 1.1rem;
border-radius: 10px;
width: 100%;
transition: background-color 0.3s ease;
box-shadow: 0 5px 15px rgba(145,85,253,0.6);
}
.btn-primary:hover {
background: #682bdf;
box-shadow: 0 8px 25px rgba(104,43,223,0.7);
}
.alert-danger {
background-color: rgba(255, 72, 66, 0.85);
border-radius: 8px;
padding: 12px 20px;
font-weight: 600;
margin-bottom: 20px;
text-align: center;
box-shadow: 0 3px 10px rgba(255,72,66,0.5);
}
.register-link {
margin-top: 15px;
font-weight: 500;
text-align: center;
}
.register-link a {
color: #fff;
text-decoration: underline;
}
.register-link a:hover {
color: #dcdcff;
}
@keyframes fadeIn {
0% {opacity: 0; transform: translateY(20px);}
100% {opacity: 1; transform: translateY(0);}
}
::placeholder {
color: rgba(255,255,255,0.7);
font-weight: 400;
}
</style>
</head>
<body>
<div class="login-wrapper">
<!-- Image Section -->
<div class="login-image-wrapper">
<h1>Library Management System</h1>
<img src="https://images.unsplash.com/photo-1524995997946-a1c2e315a42f?auto=format&fit=crop&w=800&q=80" alt="Library" class="login-image" />
</div>
<!-- Login Form Section -->
<div class="login-container shadow-lg">
<h2>User Login</h2>
<?php if ($error): ?>
<div class="alert alert-danger"><?=htmlspecialchars($error)?></div>
<?php endif; ?>
<form method="post" novalidate autocomplete="off">
<div class="mb-4">
<label for="username" class="form-label">Username</label>
<input id="username" type="text" name="username" class="form-control" placeholder="Enter your username" required value="<?=htmlspecialchars($_POST['username'] ?? '')?>" />
</div>
<div class="mb-5">
<label for="password" class="form-label">Password</label>
<input id="password" type="password" name="password" class="form-control" placeholder="Enter your password" required />
</div>
<button type="submit" class="btn btn-primary">Log In</button>
</form>
<div class="register-link">
<p>Don't have an account? <a href="register.php">Register here</a></p>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
The link “Don’t have an account? Register here” appears below the login button.
The link has subtle hover styling for better UX.
The user can click this link to open the registration page without typing the URL manually.
If you want the link somewhere else or styled differently, just let me know!