Skip to content
Snippets Groups Projects
Commit b092dd34 authored by Naufal-Nalendra's avatar Naufal-Nalendra
Browse files

chore(delete): remove unnecessary files

parent cb9364ea
Branches
Tags
No related merge requests found
<?php
class About{
public function index(){
echo 'About/index';
}
}
\ No newline at end of file
<?php
include('C:\xampp\htdocs\tugas-besar-1\app'.'/core/connection.php');
// Check if an employee number is provided in the request
if (isset($_POST['title'])) {
$title = $_POST['title'];
// Sanitize and validate the employee number input to prevent SQL injection
// Perform the DELETE operation based on the employee number
$deleteSql = "DELETE FROM book WHERE title = '$title'";
if ($conn->query($deleteSql) === TRUE) {
// Deletion was successful
$response = array('success' => true, 'message' => 'Record deleted successfully');
} else {
// Deletion failed
$response = array('success' => false, 'message' => 'Error deleting record: ' . $conn->error);
}
// Return a JSON response to the client
header('Content-Type: application/json');
echo json_encode($response);
} else {
// Handle missing or invalid input
$response = array('success' => false, 'message' => 'Invalid input');
header('Content-Type: application/json');
echo json_encode($response);
}
// Close the database connection
$conn->close();
?>
<?php
/*
include(APPURL .'/core/connection.php');
// Read URL parameters
$sortSelect = isset($_GET['sortSelect']) ? $_GET['sortSelect'] : "title";
$sortOrder = isset($_GET['sortOrder']) ? $_GET['sortOrder'] : "ASC";
$filterSelect = isset($_GET['filterSelect']) ? $_GET['filterSelect'] : "none";
$filterQuery = isset($_GET['filterQuery']) ? $_GET['filterQuery'] : "";
$searchInput = isset($_GET['searchInput']) ? $_GET['searchInput'] : "";
$activePage = isset($_GET['page']) ? intval($_GET['page']) : 1;
$itemsPerPage = 10;
// Calculate the offset
$offset = ($activePage - 1) * $itemsPerPage;
$countSql = "SELECT COUNT(*) as totalRecords FROM book";
$countResult = $conn->query($countSql);
$row = $countResult->fetch_assoc();
$totalRecords = $row['totalRecords'];
$totalPages = ceil($totalRecords / $itemsPerPage);
// Check if sortSelect and sortOrder values are set in the URL
if (isset($_GET['sortSelect']) && isset($_GET['sortOrder'])) {
// Sanitize and validate the sortSelect and sortOrder values to prevent SQL injection
$sortSelect = $_GET['sortSelect'] === "title" ? "title" : "author_id";
$sortOrder = $_GET['sortOrder'] === "descending" ? "DESC" : "ASC";
if ($_GET['sortSelect'] === "none") {
$sortSelect = null;
$sortOrder = null;
}
}
// Check if filterSelect and filterQuery values are set in the URL for filtering
if(isset($_GET['filterSelect']) && isset($_GET['filterQuery'])) {
// Sanitize and validate the filterSelect and filterQuery values to prevent SQL injection
$filterSelect = $_GET['filterSelect'] === "category" ? "category" : "author_id";
$filterQuery = $_GET['filterQuery'];
if ($_GET['filterSelect'] === "none") {
$filterSelect = null;
$filterQuery = null;
}
}
$searchInput = isset($_GET['searchInput']) ? $_GET['searchInput'] : '';
// Check if the search input is provided
$searchQuery = "";
if (isset($_GET['searchInput']) && !empty($_GET['searchInput'])) {
// Sanitize the search input to prevent SQL injection
$searchInput = mysqli_real_escape_string($conn, $_GET['searchInput']);
// Create a search query using LIKE clause for substring search
$searchQuery = " AND (title LIKE '%$searchInput%' OR author_id LIKE '%$searchInput%')";
}
// Construct the final SQL query based on sorting, filtering, and searching
$sql = "SELECT title, author_id, category FROM book WHERE 1=1"; // Initial WHERE condition
if ($filterSelect && $filterQuery) {
$sql .= " AND $filterSelect = '$filterQuery'";
}
if ($searchQuery) {
$sql .= $searchQuery;
}
if ($sortSelect && $sortOrder) {
$sql .= " ORDER BY $sortSelect $sortOrder";
}
$sql .= " LIMIT $itemsPerPage OFFSET $offset";
$result = $conn->query($sql);
?>
<script src="http://localhost:8080/public/js/search.js"></script>
*/
\ No newline at end of file
......@@ -16,6 +16,11 @@
<?php if (isset($error)) { ?>
<div class="error-message"><?php echo $error; ?></div>
<?php } ?>
<div class="login-link">
<p>Please sign in to access this page <br>
<a href="http://localhost:8080/public/login">Sign in</a>
</p>
</div>
</div>
</body>
</html>
......@@ -23,4 +23,13 @@ body {
font-family: Helvetica;
font-size: 23px;
}
.login-link p a {
color: #FFAC7F;
text-decoration: none;
font-weight: 600;
}
.login-link p a:hover {
text-decoration: underline;
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment