-
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
24 changed files
with
592 additions
and
592 deletions.
There are no files selected for viewing
File renamed without changes.
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 |
---|---|---|
@@ -1,27 +1,27 @@ | ||
<!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"> | ||
</head> | ||
<body> | ||
<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> | ||
</body> | ||
<!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"> | ||
</head> | ||
<body> | ||
<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> | ||
</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 |
---|---|---|
@@ -1,46 +1,46 @@ | ||
<?php | ||
session_start(); | ||
require 'db_config.php'; | ||
|
||
// Function to update the books.json file | ||
function updateJsonFile($conn) { | ||
$query = "SELECT * FROM books"; | ||
$result = $conn->query($query); | ||
$books = []; | ||
|
||
while ($row = $result->fetch_assoc()) { | ||
$books[] = $row; | ||
} | ||
|
||
// Encode the array to JSON and save it to the books.json file | ||
file_put_contents('books.json', json_encode($books, JSON_PRETTY_PRINT)); | ||
} | ||
|
||
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)) { | ||
die("All fields are required."); | ||
} | ||
|
||
// 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 "Book added successfully! <a href='add_book.html'>Add another book</a>"; | ||
} else { | ||
die("Error adding book: " . $stmt->error); | ||
} | ||
} | ||
<?php | ||
session_start(); | ||
require 'db_config.php'; | ||
|
||
// Function to update the books.json file | ||
function updateJsonFile($conn) { | ||
$query = "SELECT * FROM books"; | ||
$result = $conn->query($query); | ||
$books = []; | ||
|
||
while ($row = $result->fetch_assoc()) { | ||
$books[] = $row; | ||
} | ||
|
||
// Encode the array to JSON and save it to the books.json file | ||
file_put_contents('books.json', json_encode($books, JSON_PRETTY_PRINT)); | ||
} | ||
|
||
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)) { | ||
die("All fields are required."); | ||
} | ||
|
||
// 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 "Book added successfully! <a href='add_book.html'>Add another book</a>"; | ||
} else { | ||
die("Error adding book: " . $stmt->error); | ||
} | ||
} | ||
?> |
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1,48 +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; | ||
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 |
---|---|---|
@@ -1,29 +1,29 @@ | ||
<!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"> | ||
</head> | ||
<body> | ||
<header> | ||
<h1>Welcome to the Library Management System</h1> | ||
<p id="user-display"> | ||
<?php | ||
session_start(); | ||
if (isset($_SESSION['username'])) { | ||
echo "Logged in as: " . htmlspecialchars($_SESSION['username']); | ||
} else { | ||
header("Location: login.html"); | ||
} | ||
?> | ||
</p> | ||
<a href="logout.php">Logout</a> | ||
</header> | ||
<main> | ||
<a href="add_book.html">Add Book</a> | ||
<a href="search_books.html">Search Books</a> | ||
</main> | ||
</body> | ||
</html> | ||
<!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"> | ||
</head> | ||
<body> | ||
<header> | ||
<h1>Welcome to the Library Management System</h1> | ||
<p id="user-display"> | ||
<?php | ||
session_start(); | ||
if (isset($_SESSION['username'])) { | ||
echo "Logged in as: " . htmlspecialchars($_SESSION['username']); | ||
} else { | ||
header("Location: login.html"); | ||
} | ||
?> | ||
</p> | ||
<a href="logout.php">Logout</a> | ||
</header> | ||
<main> | ||
<a href="add_book.html">Add Book</a> | ||
<a href="search_books.html">Search Books</a> | ||
</main> | ||
</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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
<?php | ||
// Database configuration | ||
$host = "localhost"; | ||
$user = "root"; | ||
$password = ""; | ||
$database = "library_db"; | ||
$port = 3307; // Updated port number for phpMyAdmin | ||
|
||
// Create a database connection | ||
$conn = new mysqli($host, $user, $password, $database, $port); | ||
|
||
// Check the connection | ||
if ($conn->connect_error) { | ||
die("Connection failed: " . $conn->connect_error); | ||
} | ||
<?php | ||
// Database configuration | ||
$host = "localhost"; | ||
$user = "root"; | ||
$password = ""; | ||
$database = "library_db"; | ||
$port = 3307; // Updated port number for phpMyAdmin | ||
|
||
// Create a database connection | ||
$conn = new mysqli($host, $user, $password, $database, $port); | ||
|
||
// Check the connection | ||
if ($conn->connect_error) { | ||
die("Connection failed: " . $conn->connect_error); | ||
} | ||
?> |
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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
<?php | ||
// Define the path to the Python executable and the script | ||
$python = 'C:\\Users\\Lokesh Patra\\AppData\\Local\\Programs\\Python\\Python312\\python.exe'; // Full path to Python executable | ||
$script = 'export_books.py'; // The Python script to be executed | ||
|
||
// Execute the Python script and capture the output | ||
$output = shell_exec("\"$python\" \"$script\" 2>&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!<br>"; | ||
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); | ||
} | ||
?> | ||
<?php | ||
// Define the path to the Python executable and the script | ||
$python = 'C:\\Users\\Lokesh Patra\\AppData\\Local\\Programs\\Python\\Python312\\python.exe'; // Full path to Python executable | ||
$script = 'export_books.py'; // The Python script to be executed | ||
|
||
// Execute the Python script and capture the output | ||
$output = shell_exec("\"$python\" \"$script\" 2>&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!<br>"; | ||
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); | ||
} | ||
?> |
Oops, something went wrong.