Jasmin Weise 2023-06-11 21:54:07 +02:00
commit c726bcc3ad
1 changed files with 171 additions and 54 deletions

View File

@ -1,4 +1,3 @@
<!DOCTYPE html>
<?php <?php
session_start(); session_start();
$db_link = mysqli_connect('localhost', 'web_b-3', 'een7Ao6s', 'bibliothek_candle', '3306'); $db_link = mysqli_connect('localhost', 'web_b-3', 'een7Ao6s', 'bibliothek_candle', '3306');
@ -13,7 +12,7 @@ $db_link = mysqli_connect('localhost', 'web_b-3', 'een7Ao6s', 'bibliothek_candle
return $db_res; return $db_res;
} }
if(isset($_POST['submit'])){ if(isset($_POST['submit'])){
$kartenid = $_POST['karten-id']; $kartenid = $_POST['karten-id'];
$passwort = $_POST['password']; $passwort = $_POST['password'];
@ -21,71 +20,189 @@ $db_link = mysqli_connect('localhost', 'web_b-3', 'een7Ao6s', 'bibliothek_candle
$row = mysqli_fetch_array($existiert); $row = mysqli_fetch_array($existiert);
$karteexistiert = runSQL("SELECT COUNT(*) FROM `benutzer` WHERE `KartenID` = '$kartenid'"); $karteexistiert = runSQL("SELECT COUNT(*) FROM `benutzer` WHERE `KartenID` = '$kartenid'");
$zeile = mysqli_fetch_array($karteexistiert); $zeile = mysqli_fetch_array($karteexistiert);
if($row['COUNT(*)'] > 0){ if($row['COUNT(*)'] > 0){
$_SESSION['eingeloggt'] = 1; $_SESSION['eingeloggt'] = 1;
echo '<html> echo '<!DOCTYPE html>
<html>
<head> <head>
<meta lang="de"/> <meta lang="de"/>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<meta name="viewport" content="device=device-width, initial-scaling=1"/> <meta name="viewport" content="device=device-width, initial-scaling=1"/>
<link rel="Stylesheet" type="text/css" href="style.css"/> <link rel="Stylesheet" type="text/css" href="style.css"/>
<link rel="Stylesheet" type="text/css" href="suchergebnisse.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title>Candle Bibliothek | Meine Bücher</title> <title>Candle Bibliothek | Meine Bücher</title>
<link rel="icon" href="pictures/candle.png"> <link rel="icon" href="pictures/candle.png">
<script src="notwendiges_laden.js" defer></script> <script src="notwendiges_laden.js" defer></script>
</head> </head>
<body> <body>
<header id="header"></header> <header id="header"></header>
<div class="containerofmeinebuecher">
<p id="meinebüchertitel">Meine Bücher</p> <div class="hauptcontainer">
<h1 id="searchResult_heading">Meine Bücher</h1>
</div> <div id="searchResult_container">';
<!--Link JS file-->
<script src="burgerIcon.js"></script>
<script>
var widthissue = false;
window.addEventListener("resize", function(event) {
if(window.innerWidth > 800 && widthissue) {
widthissue = false
unset()
}
else if(window.innerWidth < 800) widthissue = true;
})
</script>
<!--Burger-->
<nav id="activeid" class="active">
<div class="navLinks">
<input class="nav-toggleclass"id="nav-toggle" type="checkbox" onclick="openNav()";>
<label for="nav-toggle" class="icon-burger" >
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</label>
</div>
</nav>
<footer id="footer" class="fuss" ></footer>
</body>
</html>';
}else if($zeile['COUNT(*)'] > 0){ $sql = "SELECT b.BuchID, b.Titel, b.Bild,
header("Location: passwort_stimmt_nicht.html"); GROUP_CONCAT(DISTINCT CONCAT(a.VorName, ' ', a.NachName)
}else{ SEPARATOR ', ') AS 'Autor',
header("Location: benutzer_existiert_nicht.html"); IF(b.Anzahl!=0, 'Verfügbar', CONCAT('Verfügbar ab: ',
(SELECT DATE_FORMAT(DATE_ADD(ab.Enddatum, INTERVAL 1 DAY)
,'%d.%m.%Y') FROM `ausgeliehenes_buch` AS ab
WHERE ab.BuchID = b.BuchID
ORDER BY ab.Reserviert ASC, ab.Enddatum ASC LIMIT 1)))
AS 'Verfügbarkeit' FROM `buch` AS b
INNER JOIN `buch_verfasst_von_autor` AS bvva
ON b.BuchID = bvva.BuchID
INNER JOIN `autor` AS a ON bvva.AutorNr = a.AutorNr
INNER JOIN `buch_hat_kategorie` AS bhk ON bhk.BuchID = b.BuchID
INNER JOIN `kategorie` AS k ON k.KategorieID = bhk.KategorieID
INNER JOIN `sprache` AS sp ON sp.SprachenID = b.SprachenID
INNER JOIN `buch_hat_stichwort` AS bhs ON bhs.BuchID = b.BuchID
INNER JOIN `stichwort` AS st ON st.StichwortID = bhs.StichwortID
GROUP BY b.BuchID
;";
$servername = "localhost";
$username = "web_b-3";
$password = "een7Ao6s";
$dbname = "bibliothek_candle";
$connection = mysqli_connect($servername, $username, $password, $dbname);
if (!$connection) {
die("Verbindung fehlgeschlagen: " . mysqli_connect_error());
} }
}else{
$result = mysqli_query($connection, $sql);
$counter = 0;
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$bookID = $row['BuchID'];
$bookCover = $row['Bild'];
$bookTitle = $row['Titel'];
$bookAuthor = $row['Autor'];
$bookAvailability = $row['Verfügbarkeit'];
if ($counter != 0) {
echo "<div class='divider'></div>";
}
// TODO: OnClick auslagern.
echo "<div id='book_container$bookID' class='book_container'
onclick='open_bookDetails(this.id)'>
<div class='bookCover_container'>
<img class='bookCover' src='book_covers/$bookCover'
alt='Kein Bild vorhanden'>
</div>
<div class='bookDetails_container'>
<h2 class='bookTitle'>$bookTitle</h2>
<div class='bookDetails'>
<p class='author'>von $bookAuthor</p>
</div>
<div class='available_container'>
<p id='available_$bookID' class='available'>
$bookAvailability</p>
<!--TODO: Auslagern-->
<script type='text/javascript'
language='JavaScript'>
(function() {
var currentElement = document.
getElementById('available_$bookID');
var parentDiv =
currentElement.parentElement;
if (currentElement.innerHTML.trim()
== 'Verfügbar') {
parentDiv.style.backgroundColor
= '#70AD47';
}
else {
parentDiv.style.backgroundColor
= '#F34343';
}
})();
</script>
</div>
<div>
<script>
</script>
<p>Helloooo</p>
</div>
</div>
<div class='shoppingCart_container'>
<div class='shoppingCart'></div>
</div>
</div>";
$counter++;
}
} else {
echo "Keine Ergebnisse.";
}
if (!$result) {
die("Ungültige SQL-Abfrage: " . mysqli_connect_error());
}
mysqli_close($connection);
}else if($zeile['COUNT(*)'] > 0){
header("Location: passwort_stimmt_nicht.html");
}else{
header("Location: benutzer_existiert_nicht.html");
}
}else{
header("Location: 404.html"); header("Location: 404.html");
} }
?> ?>
</div>
</div>
<script>
function open_bookDetails(ID) {
var data = new URLSearchParams();
data.append("bookID", ID);
var url = "http://141.19.142.11/buch_details.php?" +
data.toString();
location.href = url;
}
</script>
<!--Link JS file-->
<script src="burgerIcon.js"></script>
<script>
var widthissue = false;
window.addEventListener("resize", function(event) {
if(window.innerWidth > 800 && widthissue) {
widthissue = false
unset()
}
else if(window.innerWidth < 800) widthissue = true;
})
</script>
<!--Burger-->
<nav id="activeid" class="active">
<div class="navLinks">
<input class="nav-toggleclass"id="nav-toggle" type="checkbox" onclick="openNav()";>
<label for="nav-toggle" class="icon-burger" >
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</label>
</div>
</nav>
<footer id="footer" class="fuss" ></footer>
</body>
</html>