diff --git a/v2 Features/add_book.css b/v2 Features/add_book.css
new file mode 100644
index 0000000..e69de29
diff --git a/v2 Features/add_book.html b/v2 Features/add_book.html
new file mode 100644
index 0000000..67fce45
--- /dev/null
+++ b/v2 Features/add_book.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+ Add Book
+
+
+
+ Add a New Book
+
+
+
\ No newline at end of file
diff --git a/v2 Features/add_book.php b/v2 Features/add_book.php
new file mode 100644
index 0000000..e0d48c0
--- /dev/null
+++ b/v2 Features/add_book.php
@@ -0,0 +1,88 @@
+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 "";
+ 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 "";
+ exit;
+ } else {
+ die("Error adding book: " . $stmt->error);
+ }
+}
+?>
+
+
+
+
+
+
+ Add Book
+
+
+
+
+
+
+ Add a New Book
+
+
+
+
\ No newline at end of file
diff --git a/v2 Features/books.json b/v2 Features/books.json
new file mode 100644
index 0000000..b2c2265
--- /dev/null
+++ b/v2 Features/books.json
@@ -0,0 +1,30 @@
+[
+ {
+ "id": "1",
+ "title": "1st",
+ "author": "Sapiens",
+ "publication_year": "2001",
+ "genre": "Life"
+ },
+ {
+ "id": "2",
+ "title": "1stest",
+ "author": "H Sapiens",
+ "publication_year": "2001",
+ "genre": "Life"
+ },
+ {
+ "id": "3",
+ "title": "First",
+ "author": "Homo S",
+ "publication_year": "2001",
+ "genre": "Life"
+ },
+ {
+ "id": "7",
+ "title": "new",
+ "author": "first",
+ "publication_year": "2001",
+ "genre": "Evolution"
+ }
+]
\ No newline at end of file
diff --git a/v2 Features/books.xml b/v2 Features/books.xml
new file mode 100644
index 0000000..e536f32
--- /dev/null
+++ b/v2 Features/books.xml
@@ -0,0 +1,2 @@
+
+42ndHabilis2002Evolution6featuresecond2002tested8sample2nd2002tested
\ No newline at end of file
diff --git a/v2 Features/common.css b/v2 Features/common.css
new file mode 100644
index 0000000..37fe235
--- /dev/null
+++ b/v2 Features/common.css
@@ -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;
+}
\ No newline at end of file
diff --git a/v2 Features/dashboard.html b/v2 Features/dashboard.html
new file mode 100644
index 0000000..683f45a
--- /dev/null
+++ b/v2 Features/dashboard.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+ Dashboard
+
+
+
+
+ Welcome to the Dashboard
+ Add Book
+ Search Books
+
+
+
+
\ No newline at end of file
diff --git a/v2 Features/dashboard.php b/v2 Features/dashboard.php
new file mode 100644
index 0000000..3126b55
--- /dev/null
+++ b/v2 Features/dashboard.php
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+ Dashboard
+
+
+
+
+
+
+ Welcome to Your Dashboard
+ Hello, ! Here are your options:
+
+
+
+
diff --git a/v2 Features/db_config.php b/v2 Features/db_config.php
new file mode 100644
index 0000000..1f2191e
--- /dev/null
+++ b/v2 Features/db_config.php
@@ -0,0 +1,16 @@
+connect_error) {
+ die("Connection failed: " . $conn->connect_error);
+}
+?>
\ No newline at end of file
diff --git a/v2 Features/export_books.php b/v2 Features/export_books.php
new file mode 100644
index 0000000..380c6ea
--- /dev/null
+++ b/v2 Features/export_books.php
@@ -0,0 +1,16 @@
+&1"); // Ensure paths with spaces are handled properly
+
+// Check if the script executed successfully and output the results
+if ($output) {
+ echo "Books exported to books.xml successfully!
";
+ echo "Python script output: " . nl2br($output); // nl2br to add line breaks for better readability
+} else {
+ echo "Failed to export books to XML. Error: " . nl2br($output);
+}
+?>
diff --git a/v2 Features/export_books.py b/v2 Features/export_books.py
new file mode 100644
index 0000000..c0610ed
--- /dev/null
+++ b/v2 Features/export_books.py
@@ -0,0 +1,26 @@
+import json
+import xml.etree.ElementTree as ET
+import os
+
+# Ensure the books.json file exists and is populated
+if os.path.exists('books.json'):
+ with open('books.json', 'r') as file:
+ books = json.load(file)
+
+ # Create XML root element
+ root = ET.Element('books')
+
+ # Add book entries to XML
+ for book in books:
+ book_element = ET.SubElement(root, 'book')
+ for key, value in book.items():
+ child = ET.SubElement(book_element, key)
+ child.text = str(value)
+
+ # Write the XML data to a file
+ tree = ET.ElementTree(root)
+ tree.write('books.xml', encoding='utf-8', xml_declaration=True)
+ print("Books exported to books.xml")
+
+else:
+ print("Error: books.json not found.")
\ No newline at end of file
diff --git a/v2 Features/index.css b/v2 Features/index.css
new file mode 100644
index 0000000..d59bcce
--- /dev/null
+++ b/v2 Features/index.css
@@ -0,0 +1,43 @@
+main {
+ text-align: center;
+ padding: 2em;
+ background-color: #f9f9f9;
+}
+
+h2 {
+ color: #333;
+}
+
+p {
+ font-size: 1.2em;
+ margin: 1em 0;
+}
+
+.actions {
+ margin-top: 2em;
+}
+
+.actions .btn {
+ text-decoration: none;
+ color: white;
+ background-color: #333;
+ padding: 0.8em 1.5em;
+ border-radius: 5px;
+ margin: 0 1em;
+ font-size: 1em;
+ transition: background-color 0.3s;
+}
+
+.actions .btn:hover {
+ background-color: #555;
+}
+
+footer {
+ text-align: center;
+ padding: 1em 0;
+ background-color: #333;
+ color: white;
+ position: absolute;
+ bottom: 0;
+ width: 100%;
+}
diff --git a/v2 Features/index.html b/v2 Features/index.html
new file mode 100644
index 0000000..225748d
--- /dev/null
+++ b/v2 Features/index.html
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+ Library Management System
+
+
+
+
+
+
+
+ Manage Your Books Efficiently
+
+ Welcome, ! Manage books, search the library, and more.
+
+ Register or Log In to manage books, search the library, and more!
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/v2 Features/index.php b/v2 Features/index.php
new file mode 100644
index 0000000..144e09e
--- /dev/null
+++ b/v2 Features/index.php
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+ Library Management System
+
+
+
+
+
+
+
+
+ Manage Your Books Efficiently
+
+
+ Welcome back, ! Use the menu above to navigate.
+
+ Register or Log In to manage books, search the library, and more!
+
+
+
+
+
+
+
+
+
+
diff --git a/v2 Features/login.css b/v2 Features/login.css
new file mode 100644
index 0000000..e69de29
diff --git a/v2 Features/login.html b/v2 Features/login.html
new file mode 100644
index 0000000..00526ae
--- /dev/null
+++ b/v2 Features/login.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+ User Login
+
+
+
+
+
+ Library Management System
+
+
+
+
diff --git a/v2 Features/login.php b/v2 Features/login.php
new file mode 100644
index 0000000..3849903
--- /dev/null
+++ b/v2 Features/login.php
@@ -0,0 +1,25 @@
+prepare("SELECT * FROM users WHERE email = ? OR username = ?");
+ $stmt->bind_param("ss", $username_email, $username_email);
+ $stmt->execute();
+ $result = $stmt->get_result();
+ $user = $result->fetch_assoc();
+
+ if ($user && password_verify($password, $user['password'])) {
+ $_SESSION['user_id'] = $user['id'];
+ $_SESSION['username'] = $user['username']; // Set username in session
+ header("Location: dashboard.php");
+ exit;
+ } else {
+ echo "Invalid credentials. Try again";
+ }
+}
+?>
\ No newline at end of file
diff --git a/v2 Features/logout.php b/v2 Features/logout.php
new file mode 100644
index 0000000..b9091dc
--- /dev/null
+++ b/v2 Features/logout.php
@@ -0,0 +1,15 @@
+
+ alert('$username logged out successfully!');
+ window.location.href = 'index.php';
+ ";
+} else {
+ header("Location: index.php");
+ exit;
+}
+?>
diff --git a/v2 Features/navbar.php b/v2 Features/navbar.php
new file mode 100644
index 0000000..147f462
--- /dev/null
+++ b/v2 Features/navbar.php
@@ -0,0 +1,46 @@
+
+
+
\ No newline at end of file
diff --git a/v2 Features/register.css b/v2 Features/register.css
new file mode 100644
index 0000000..e69de29
diff --git a/v2 Features/register.html b/v2 Features/register.html
new file mode 100644
index 0000000..419df81
--- /dev/null
+++ b/v2 Features/register.html
@@ -0,0 +1,28 @@
+
+
+
+
+
+ User Registration
+
+
+
+
+
+ Library Management System
+
+
+
+
diff --git a/v2 Features/register.php b/v2 Features/register.php
new file mode 100644
index 0000000..226ecdb
--- /dev/null
+++ b/v2 Features/register.php
@@ -0,0 +1,30 @@
+prepare("SELECT * FROM users WHERE email = ?");
+ $checkQuery->bind_param("s", $email);
+ $checkQuery->execute();
+ $result = $checkQuery->get_result();
+
+ if ($result->num_rows > 0) {
+ echo "Email already exists! Go back";
+ exit;
+ }
+
+ // Insert user into the database
+ $stmt = $conn->prepare("INSERT INTO users (username, email, password) VALUES (?, ?, ?)");
+ $stmt->bind_param("sss", $username, $email, $password);
+
+ if ($stmt->execute()) {
+ echo "Registration successful! Login here";
+ } else {
+ echo "Error registering user.";
+ }
+}
+?>
diff --git a/v2 Features/search.js b/v2 Features/search.js
new file mode 100644
index 0000000..b2ae60a
--- /dev/null
+++ b/v2 Features/search.js
@@ -0,0 +1,34 @@
+document.getElementById("searchBookForm").addEventListener("submit", async function (e) {
+ e.preventDefault();
+ const title = document.getElementById("search_title").value.trim();
+ const author = document.getElementById("search_author").value.trim();
+ const year = document.getElementById("search_year").value.trim();
+
+ // Fetch search results using PHP backend
+ const response = await fetch("search_books.php", {
+ method: "POST",
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
+ body: new URLSearchParams({ title, author, year }),
+ });
+ const books = await response.json();
+
+ const tableBody = document.getElementById("results").querySelector("tbody");
+ tableBody.innerHTML = ""; // Clear previous results
+
+ books.forEach(book => {
+ const row = `
+ ${book.id} |
+ ${book.title} |
+ ${book.author} |
+ ${book.publication_year} |
+ ${book.genre} |
+
`;
+ tableBody.innerHTML += row;
+ });
+});
+
+// Export to XML handler
+document.getElementById("exportXML").addEventListener("click", async function () {
+ await fetch("export_books.php");
+ alert("Books exported to XML!");
+});
diff --git a/v2 Features/search_books.css b/v2 Features/search_books.css
new file mode 100644
index 0000000..e69de29
diff --git a/v2 Features/search_books.html b/v2 Features/search_books.html
new file mode 100644
index 0000000..1fd4b1e
--- /dev/null
+++ b/v2 Features/search_books.html
@@ -0,0 +1,106 @@
+
+
+
+
+
+ Search Books
+
+
+
+ Search Books
+
+
+ Search Results:
+
+
+
+ Title |
+ Author |
+ Publication Year |
+ Genre |
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/v2 Features/search_books.php b/v2 Features/search_books.php
new file mode 100644
index 0000000..8cb2806
--- /dev/null
+++ b/v2 Features/search_books.php
@@ -0,0 +1,48 @@
+real_escape_string($title) . "%'";
+ }
+ if ($author) {
+ $query .= " AND author LIKE '%" . $conn->real_escape_string($author) . "%'";
+ }
+ if ($publication_year) {
+ $query .= " AND publication_year = " . (int)$publication_year;
+ }
+
+ // Execute the query and store the results
+ $search_results = $conn->query($query);
+ $books = [];
+
+ // Fetch the results if available
+ if ($search_results && $search_results->num_rows > 0) {
+ while ($row = $search_results->fetch_assoc()) {
+ $books[] = $row;
+ }
+
+ // Optionally, update books.json file if needed (store the results in a file)
+ file_put_contents('books.json', json_encode($books, JSON_PRETTY_PRINT));
+ }
+
+ // Set the content type to JSON and return the results as JSON
+ header('Content-Type: application/json');
+ echo json_encode($books); // Send the results back to the client in JSON format
+ exit;
+}
diff --git a/v2 Features/validation.js b/v2 Features/validation.js
new file mode 100644
index 0000000..1f36f84
--- /dev/null
+++ b/v2 Features/validation.js
@@ -0,0 +1,13 @@
+document.getElementById("addBookForm").addEventListener("submit", function (e) {
+ const title = document.getElementById("title").value.trim();
+ const author = document.getElementById("author").value.trim();
+ const publicationYear = parseInt(document.getElementById("publication_year").value);
+ const genre = document.getElementById("genre").value.trim();
+
+ if (!title || !author || !genre || isNaN(publicationYear) || publicationYear <= 2000) {
+ e.preventDefault();
+ alert("All fields are required, and the publication year must be greater than 2000.");
+ } else {
+ alert("Book successfully added!");
+ }
+});