Skip to content

Commit 8000845

Browse files
committed
Fashion Designed! [ v3.0 ]
1 parent dcb298b commit 8000845

28 files changed

+1332
-0
lines changed

v3 Fashion/add_book.css

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/* General Styles */
2+
body {
3+
font-family: 'Cambria', serif;
4+
background-color: #f4f4f4;
5+
color: #333;
6+
margin: 0;
7+
padding: 0;
8+
}
9+
10+
header {
11+
background-color: #008080; /* Teal color */
12+
color: white;
13+
text-align: center;
14+
padding: 20px 0;
15+
margin-bottom: 40px;
16+
}
17+
18+
header h1 {
19+
font-size: 2.5rem;
20+
margin: 0;
21+
}
22+
23+
main {
24+
padding: 40px 10px;
25+
text-align: center;
26+
}
27+
28+
main h1 {
29+
color: #008080;
30+
font-size: 2.2rem;
31+
margin-bottom: 20px;
32+
}
33+
34+
form {
35+
background-color: #fff;
36+
padding: 30px;
37+
border-radius: 8px;
38+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
39+
width: 50%;
40+
margin: 0 auto;
41+
box-sizing: border-box;
42+
}
43+
44+
form label {
45+
display: block;
46+
font-size: 1rem;
47+
margin: 10px 0 5px;
48+
}
49+
50+
form input {
51+
width: 100%;
52+
padding: 12px;
53+
font-size: 1rem;
54+
margin-bottom: 15px;
55+
border: 1px solid #ccc;
56+
border-radius: 4px;
57+
}
58+
59+
form button {
60+
background-color: #008080;
61+
color: white;
62+
padding: 12px 20px;
63+
border: none;
64+
border-radius: 4px;
65+
font-size: 1.2rem;
66+
cursor: pointer;
67+
transition: background-color 0.3s ease;
68+
}
69+
70+
form button:hover {
71+
background-color: #006666;
72+
}
73+
74+
footer {
75+
background-color: #008080;
76+
color: white;
77+
text-align: center;
78+
padding: 10px;
79+
position: absolute;
80+
bottom: 0;
81+
width: 100%;
82+
}

v3 Fashion/add_book.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Add Book</title>
7+
<link rel="stylesheet" href="common.css">
8+
<link rel="stylesheet" href="add_book.css">
9+
</head>
10+
<body>
11+
<?php include 'navbar.php'; ?>
12+
13+
<main>
14+
<h1>Add a New Book</h1>
15+
<form action="add_book.php" method="POST">
16+
<label for="title">Title:</label>
17+
<input type="text" id="title" name="title" required><br>
18+
19+
<label for="author">Author:</label>
20+
<input type="text" id="author" name="author" required><br>
21+
22+
<label for="publication_year">Publication Year:</label>
23+
<input type="number" id="publication_year" name="publication_year" min="2000" required><br>
24+
25+
<label for="genre">Genre:</label>
26+
<input type="text" id="genre" name="genre" required><br>
27+
28+
<button type="submit">Add Book</button>
29+
</form>
30+
</main>
31+
32+
<footer>
33+
<p>&copy; 2024 Library Management System</p>
34+
</footer>
35+
</body>
36+
</html>

v3 Fashion/add_book.php

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?php
2+
// Start the session
3+
session_start();
4+
require 'db_config.php';
5+
6+
// Redirect if the user is not logged in
7+
if (!isset($_SESSION['username'])) {
8+
header("Location: login.html");
9+
exit;
10+
}
11+
12+
// Function to update the books.json file after adding a new book
13+
function updateJsonFile($conn) {
14+
$query = "SELECT * FROM books";
15+
$result = $conn->query($query);
16+
$books = [];
17+
18+
while ($row = $result->fetch_assoc()) {
19+
$books[] = $row;
20+
}
21+
22+
// Save the books array to books.json
23+
file_put_contents('books.json', json_encode($books, JSON_PRETTY_PRINT));
24+
}
25+
26+
// Handle form submission
27+
if ($_SERVER["REQUEST_METHOD"] === "POST") {
28+
// Retrieve form data
29+
$title = $_POST['title'] ?? '';
30+
$author = $_POST['author'] ?? '';
31+
$publication_year = $_POST['publication_year'] ?? 0;
32+
$genre = $_POST['genre'] ?? '';
33+
34+
// Validate form data
35+
if (empty($title) || empty($author) || empty($publication_year) || empty($genre)) {
36+
echo "<script>alert('All fields are required.'); window.location.href='add_book.php';</script>";
37+
exit;
38+
}
39+
40+
// Insert data into the database
41+
$stmt = $conn->prepare("INSERT INTO books (title, author, publication_year, genre) VALUES (?, ?, ?, ?)");
42+
if (!$stmt) {
43+
die("Prepare failed: " . $conn->error);
44+
}
45+
46+
$stmt->bind_param("ssis", $title, $author, $publication_year, $genre);
47+
48+
if ($stmt->execute()) {
49+
updateJsonFile($conn); // Update the JSON file after adding the book
50+
echo "<script>alert('Book added successfully!'); window.location.href='add_book.php';</script>";
51+
exit;
52+
} else {
53+
die("Error adding book: " . $stmt->error);
54+
}
55+
}
56+
?>
57+
58+
<!DOCTYPE html>
59+
<html lang="en">
60+
<head>
61+
<meta charset="UTF-8">
62+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
63+
<title>Add Book</title>
64+
<link rel="stylesheet" href="common.css">
65+
<link rel="stylesheet" href="add_book.css">
66+
</head>
67+
<body>
68+
<?php include 'navbar.php'; ?>
69+
70+
<main>
71+
<h1>Add a New Book</h1>
72+
<form action="add_book.php" method="POST">
73+
<label for="title">Title:</label>
74+
<input type="text" id="title" name="title" required><br>
75+
76+
<label for="author">Author:</label>
77+
<input type="text" id="author" name="author" required><br>
78+
79+
<label for="publication_year">Publication Year:</label>
80+
<input type="number" id="publication_year" name="publication_year" min="2000" required><br>
81+
82+
<label for="genre">Genre:</label>
83+
<input type="text" id="genre" name="genre" required><br>
84+
85+
<button type="submit">Add Book</button>
86+
</form>
87+
</main>
88+
89+
<footer>
90+
<p>&copy; 2024 Library Management System</p>
91+
</footer>
92+
</body>
93+
</html>

v3 Fashion/books.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[
2+
{
3+
"id": "10",
4+
"title": "3rd",
5+
"author": "H Rudolfensis",
6+
"publication_year": "2003",
7+
"genre": "Evolution"
8+
}
9+
]

v3 Fashion/books.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<books><book><id>10</id><title>3rd</title><author>H Rudolfensis</author><publication_year>2003</publication_year><genre>Evolution</genre></book></books>

v3 Fashion/common.css

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
body {
2+
font-family: Arial, sans-serif;
3+
margin: 0;
4+
padding: 0;
5+
background-color: #f4f4f9;
6+
}
7+
8+
header {
9+
background-color: #333;
10+
color: white;
11+
padding: 1em;
12+
text-align: center;
13+
}
14+
15+
form {
16+
width: 50%;
17+
margin: 2em auto;
18+
padding: 2em;
19+
background: white;
20+
border: 1px solid #ccc;
21+
border-radius: 8px;
22+
}
23+
24+
form label {
25+
display: block;
26+
margin: 0.5em 0 0.2em;
27+
}
28+
29+
form input {
30+
width: 100%;
31+
padding: 0.5em;
32+
margin-bottom: 1em;
33+
border: 1px solid #ccc;
34+
border-radius: 4px;
35+
}
36+
37+
form button {
38+
background-color: #333;
39+
color: white;
40+
padding: 0.7em 1.5em;
41+
border: none;
42+
border-radius: 4px;
43+
cursor: pointer;
44+
}
45+
46+
form button:hover {
47+
background-color: #555;
48+
}

v3 Fashion/dashboard.css

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/* General Styles */
2+
body {
3+
font-family: 'Cambria', serif;
4+
background-color: #f4f4f4;
5+
color: #333;
6+
margin: 0;
7+
padding: 0;
8+
}
9+
10+
header {
11+
background-color: #008080; /* Teal color */
12+
color: white;
13+
text-align: center;
14+
padding: 20px 0;
15+
margin-bottom: 40px;
16+
}
17+
18+
header h1 {
19+
font-size: 2.5rem;
20+
margin: 0;
21+
}
22+
23+
main {
24+
text-align: center;
25+
padding: 30px 10px;
26+
}
27+
28+
main h2 {
29+
color: #008080;
30+
font-size: 2rem;
31+
margin-bottom: 30px;
32+
}
33+
34+
.actions {
35+
display: flex;
36+
justify-content: center;
37+
gap: 20px;
38+
}
39+
40+
.actions a {
41+
background-color: #008080;
42+
color: white;
43+
padding: 12px 20px;
44+
text-decoration: none;
45+
border-radius: 4px;
46+
font-size: 1.1rem;
47+
transition: background-color 0.3s;
48+
}
49+
50+
.actions a:hover {
51+
background-color: #006666;
52+
}
53+
54+
footer {
55+
background-color: #008080;
56+
color: white;
57+
text-align: center;
58+
padding: 10px;
59+
position: absolute;
60+
bottom: 0;
61+
width: 100%;
62+
}

v3 Fashion/dashboard.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php include 'navbar.php'; ?>
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Dashboard</title>
8+
<link rel="stylesheet" href="common.css">
9+
<link rel="stylesheet" href="dashboard.css">
10+
</head>
11+
<body>
12+
<main>
13+
<h2>Welcome to the Dashboard</h2>
14+
<div class="actions">
15+
<a href="add_book.html">Add Book</a>
16+
<a href="search_books.html">Search Books</a>
17+
</div>
18+
</main>
19+
<footer>
20+
<p>&copy; 2024 Library Management System</p>
21+
</footer>
22+
</body>
23+
</html>

v3 Fashion/dashboard.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php include 'navbar.php'; ?>
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Dashboard</title>
8+
<link rel="stylesheet" href="common.css">
9+
<link rel="stylesheet" href="dashboard.css">
10+
</head>
11+
<body>
12+
<main>
13+
<h2>Welcome to the Dashboard</h2>
14+
<div class="actions">
15+
<a href="add_book.php">Add Book</a>
16+
<a href="search_books.html">Search Books</a>
17+
</div>
18+
</main>
19+
<footer>
20+
<p>&copy; 2024 Library Management System</p>
21+
</footer>
22+
</body>
23+
</html>

0 commit comments

Comments
 (0)