-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,332 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* General Styles */ | ||
body { | ||
font-family: 'Cambria', serif; | ||
background-color: #f4f4f4; | ||
color: #333; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
header { | ||
background-color: #008080; /* Teal color */ | ||
color: white; | ||
text-align: center; | ||
padding: 20px 0; | ||
margin-bottom: 40px; | ||
} | ||
|
||
header h1 { | ||
font-size: 2.5rem; | ||
margin: 0; | ||
} | ||
|
||
main { | ||
padding: 40px 10px; | ||
text-align: center; | ||
} | ||
|
||
main h1 { | ||
color: #008080; | ||
font-size: 2.2rem; | ||
margin-bottom: 20px; | ||
} | ||
|
||
form { | ||
background-color: #fff; | ||
padding: 30px; | ||
border-radius: 8px; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | ||
width: 50%; | ||
margin: 0 auto; | ||
box-sizing: border-box; | ||
} | ||
|
||
form label { | ||
display: block; | ||
font-size: 1rem; | ||
margin: 10px 0 5px; | ||
} | ||
|
||
form input { | ||
width: 100%; | ||
padding: 12px; | ||
font-size: 1rem; | ||
margin-bottom: 15px; | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
} | ||
|
||
form button { | ||
background-color: #008080; | ||
color: white; | ||
padding: 12px 20px; | ||
border: none; | ||
border-radius: 4px; | ||
font-size: 1.2rem; | ||
cursor: pointer; | ||
transition: background-color 0.3s ease; | ||
} | ||
|
||
form button:hover { | ||
background-color: #006666; | ||
} | ||
|
||
footer { | ||
background-color: #008080; | ||
color: white; | ||
text-align: center; | ||
padding: 10px; | ||
position: absolute; | ||
bottom: 0; | ||
width: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Add Book</title> | ||
<link rel="stylesheet" href="common.css"> | ||
<link rel="stylesheet" href="add_book.css"> | ||
</head> | ||
<body> | ||
<?php include 'navbar.php'; ?> | ||
|
||
<main> | ||
<h1>Add a New Book</h1> | ||
<form action="add_book.php" method="POST"> | ||
<label for="title">Title:</label> | ||
<input type="text" id="title" name="title" required><br> | ||
|
||
<label for="author">Author:</label> | ||
<input type="text" id="author" name="author" required><br> | ||
|
||
<label for="publication_year">Publication Year:</label> | ||
<input type="number" id="publication_year" name="publication_year" min="2000" required><br> | ||
|
||
<label for="genre">Genre:</label> | ||
<input type="text" id="genre" name="genre" required><br> | ||
|
||
<button type="submit">Add Book</button> | ||
</form> | ||
</main> | ||
|
||
<footer> | ||
<p>© 2024 Library Management System</p> | ||
</footer> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
// Start the session | ||
session_start(); | ||
require 'db_config.php'; | ||
|
||
// Redirect if the user is not logged in | ||
if (!isset($_SESSION['username'])) { | ||
header("Location: login.html"); | ||
exit; | ||
} | ||
|
||
// Function to update the books.json file after adding a new book | ||
function updateJsonFile($conn) { | ||
$query = "SELECT * FROM books"; | ||
$result = $conn->query($query); | ||
$books = []; | ||
|
||
while ($row = $result->fetch_assoc()) { | ||
$books[] = $row; | ||
} | ||
|
||
// Save the books array to books.json | ||
file_put_contents('books.json', json_encode($books, JSON_PRETTY_PRINT)); | ||
} | ||
|
||
// Handle form submission | ||
if ($_SERVER["REQUEST_METHOD"] === "POST") { | ||
// Retrieve form data | ||
$title = $_POST['title'] ?? ''; | ||
$author = $_POST['author'] ?? ''; | ||
$publication_year = $_POST['publication_year'] ?? 0; | ||
$genre = $_POST['genre'] ?? ''; | ||
|
||
// Validate form data | ||
if (empty($title) || empty($author) || empty($publication_year) || empty($genre)) { | ||
echo "<script>alert('All fields are required.'); window.location.href='add_book.php';</script>"; | ||
exit; | ||
} | ||
|
||
// Insert data into the database | ||
$stmt = $conn->prepare("INSERT INTO books (title, author, publication_year, genre) VALUES (?, ?, ?, ?)"); | ||
if (!$stmt) { | ||
die("Prepare failed: " . $conn->error); | ||
} | ||
|
||
$stmt->bind_param("ssis", $title, $author, $publication_year, $genre); | ||
|
||
if ($stmt->execute()) { | ||
updateJsonFile($conn); // Update the JSON file after adding the book | ||
echo "<script>alert('Book added successfully!'); window.location.href='add_book.php';</script>"; | ||
exit; | ||
} else { | ||
die("Error adding book: " . $stmt->error); | ||
} | ||
} | ||
?> | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Add Book</title> | ||
<link rel="stylesheet" href="common.css"> | ||
<link rel="stylesheet" href="add_book.css"> | ||
</head> | ||
<body> | ||
<?php include 'navbar.php'; ?> | ||
|
||
<main> | ||
<h1>Add a New Book</h1> | ||
<form action="add_book.php" method="POST"> | ||
<label for="title">Title:</label> | ||
<input type="text" id="title" name="title" required><br> | ||
|
||
<label for="author">Author:</label> | ||
<input type="text" id="author" name="author" required><br> | ||
|
||
<label for="publication_year">Publication Year:</label> | ||
<input type="number" id="publication_year" name="publication_year" min="2000" required><br> | ||
|
||
<label for="genre">Genre:</label> | ||
<input type="text" id="genre" name="genre" required><br> | ||
|
||
<button type="submit">Add Book</button> | ||
</form> | ||
</main> | ||
|
||
<footer> | ||
<p>© 2024 Library Management System</p> | ||
</footer> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ | ||
{ | ||
"id": "10", | ||
"title": "3rd", | ||
"author": "H Rudolfensis", | ||
"publication_year": "2003", | ||
"genre": "Evolution" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<books><book><id>10</id><title>3rd</title><author>H Rudolfensis</author><publication_year>2003</publication_year><genre>Evolution</genre></book></books> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
margin: 0; | ||
padding: 0; | ||
background-color: #f4f4f9; | ||
} | ||
|
||
header { | ||
background-color: #333; | ||
color: white; | ||
padding: 1em; | ||
text-align: center; | ||
} | ||
|
||
form { | ||
width: 50%; | ||
margin: 2em auto; | ||
padding: 2em; | ||
background: white; | ||
border: 1px solid #ccc; | ||
border-radius: 8px; | ||
} | ||
|
||
form label { | ||
display: block; | ||
margin: 0.5em 0 0.2em; | ||
} | ||
|
||
form input { | ||
width: 100%; | ||
padding: 0.5em; | ||
margin-bottom: 1em; | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
} | ||
|
||
form button { | ||
background-color: #333; | ||
color: white; | ||
padding: 0.7em 1.5em; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
} | ||
|
||
form button:hover { | ||
background-color: #555; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* General Styles */ | ||
body { | ||
font-family: 'Cambria', serif; | ||
background-color: #f4f4f4; | ||
color: #333; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
header { | ||
background-color: #008080; /* Teal color */ | ||
color: white; | ||
text-align: center; | ||
padding: 20px 0; | ||
margin-bottom: 40px; | ||
} | ||
|
||
header h1 { | ||
font-size: 2.5rem; | ||
margin: 0; | ||
} | ||
|
||
main { | ||
text-align: center; | ||
padding: 30px 10px; | ||
} | ||
|
||
main h2 { | ||
color: #008080; | ||
font-size: 2rem; | ||
margin-bottom: 30px; | ||
} | ||
|
||
.actions { | ||
display: flex; | ||
justify-content: center; | ||
gap: 20px; | ||
} | ||
|
||
.actions a { | ||
background-color: #008080; | ||
color: white; | ||
padding: 12px 20px; | ||
text-decoration: none; | ||
border-radius: 4px; | ||
font-size: 1.1rem; | ||
transition: background-color 0.3s; | ||
} | ||
|
||
.actions a:hover { | ||
background-color: #006666; | ||
} | ||
|
||
footer { | ||
background-color: #008080; | ||
color: white; | ||
text-align: center; | ||
padding: 10px; | ||
position: absolute; | ||
bottom: 0; | ||
width: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php include 'navbar.php'; ?> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Dashboard</title> | ||
<link rel="stylesheet" href="common.css"> | ||
<link rel="stylesheet" href="dashboard.css"> | ||
</head> | ||
<body> | ||
<main> | ||
<h2>Welcome to the Dashboard</h2> | ||
<div class="actions"> | ||
<a href="add_book.html">Add Book</a> | ||
<a href="search_books.html">Search Books</a> | ||
</div> | ||
</main> | ||
<footer> | ||
<p>© 2024 Library Management System</p> | ||
</footer> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php include 'navbar.php'; ?> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Dashboard</title> | ||
<link rel="stylesheet" href="common.css"> | ||
<link rel="stylesheet" href="dashboard.css"> | ||
</head> | ||
<body> | ||
<main> | ||
<h2>Welcome to the Dashboard</h2> | ||
<div class="actions"> | ||
<a href="add_book.php">Add Book</a> | ||
<a href="search_books.html">Search Books</a> | ||
</div> | ||
</main> | ||
<footer> | ||
<p>© 2024 Library Management System</p> | ||
</footer> | ||
</body> | ||
</html> |
Oops, something went wrong.