add bootstrap file for centralized error handling and session management; update wishlist page with category-based product display
This commit is contained in:
parent
1fb66ce0a1
commit
f9b096cbeb
4
assets/icons/wishlist.svg
Normal file
4
assets/icons/wishlist.svg
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M8 6.00067L21 6.00139M8 12.0007L21 12.0015M8 18.0007L21 18.0015M3.5 6H3.51M3.5 12H3.51M3.5 18H3.51M4 6C4 6.27614 3.77614 6.5 3.5 6.5C3.22386 6.5 3 6.27614 3 6C3 5.72386 3.22386 5.5 3.5 5.5C3.77614 5.5 4 5.72386 4 6ZM4 12C4 12.2761 3.77614 12.5 3.5 12.5C3.22386 12.5 3 12.2761 3 12C3 11.7239 3.22386 11.5 3.5 11.5C3.77614 11.5 4 11.7239 4 12ZM4 18C4 18.2761 3.77614 18.5 3.5 18.5C3.22386 18.5 3 18.2761 3 18C3 17.7239 3.22386 17.5 3.5 17.5C3.77614 17.5 4 17.7239 4 18Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 788 B |
11
header.php
11
header.php
@ -33,9 +33,6 @@
|
||||
<a href="index.php" class="nav__link">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="nav__item">
|
||||
<a href="wunschliste.php" class="nav__link">Wunschliste</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- Close button -->
|
||||
@ -46,13 +43,17 @@
|
||||
|
||||
<div class="nav__actions">
|
||||
<!-- Login link -->
|
||||
|
||||
<a class="nav__login nav__wishlist" href="wunschliste.php" aria-label="Wunschliste">
|
||||
<svg class="icon icon-user" viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="M8 6.00067L21 6.00139M8 12.0007L21 12.0015M8 18.0007L21 18.0015M3.5 6H3.51M3.5 12H3.51M3.5 18H3.51M4 6C4 6.27614 3.77614 6.5 3.5 6.5C3.22386 6.5 3 6.27614 3 6C3 5.72386 3.22386 5.5 3.5 5.5C3.77614 5.5 4 5.72386 4 6ZM4 12C4 12.2761 3.77614 12.5 3.5 12.5C3.22386 12.5 3 12.2761 3 12C3 11.7239 3.22386 11.5 3.5 11.5C3.77614 11.5 4 11.7239 4 12ZM4 18C4 18.2761 3.77614 18.5 3.5 18.5C3.22386 18.5 3 18.2761 3 18C3 17.7239 3.22386 17.5 3.5 17.5C3.77614 17.5 4 17.7239 4 18Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</a>
|
||||
<a class="nav__login" href="account.php" aria-label="Login">
|
||||
<svg class="icon icon-user" viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="M4 22C4 17.5817 7.58172 14 12 14C16.4183 14 20 17.5817 20 22H18C18 18.6863 15.3137 16 12 16C8.68629 16 6 18.6863 6 22H4ZM12 13C8.685 13 6 10.315 6 7C6 3.685 8.685 1 12 1C15.315 1 18 3.685 18 7C18 10.315 15.315 13 12 13ZM12 11C14.21 11 16 9.21 16 7C16 4.79 14.21 3 12 3C9.79 3 8 4.79 8 7C8 9.21 9.79 11 12 11Z"/>
|
||||
</svg>
|
||||
</a>
|
||||
|
||||
|
||||
<!-- Toggle button -->
|
||||
<div class="nav__toggle" id="nav-toggle">
|
||||
<i class="ri-menu-line"></i>
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
require_once __DIR__ . '/lib/bootstrap.php';
|
||||
?>
|
||||
|
||||
<?php include 'header.php'; ?>
|
||||
|
||||
12
lib/bootstrap.php
Normal file
12
lib/bootstrap.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// Zentraler Bootstrap: muss vor jeglicher HTML-Ausgabe inkludiert werden.
|
||||
// - startet die Session genau einmal
|
||||
// - setzt sinnvolle PHP-Error-Settings für die Entwicklung
|
||||
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('display_startup_errors', '1');
|
||||
error_reporting(E_ALL);
|
||||
|
||||
if (session_status() !== PHP_SESSION_ACTIVE) {
|
||||
session_start();
|
||||
}
|
||||
@ -175,6 +175,12 @@ main
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
/* Wunschliste-Icon immer weiß (SVG nutzt currentColor) */
|
||||
.nav__wishlist,
|
||||
.nav__wishlist:hover {
|
||||
color: var(--text-invert);
|
||||
}
|
||||
|
||||
/* ==========================================================
|
||||
TOGGLE / CLOSE
|
||||
========================================================== */
|
||||
|
||||
@ -1,5 +1,97 @@
|
||||
<?php include 'header.php'; ?>
|
||||
|
||||
<p>Secret pimmel</p>
|
||||
<?php
|
||||
// login.php
|
||||
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
session_start();
|
||||
|
||||
// 1) DB-Verbindung (einmal)
|
||||
$servername = "localhost";
|
||||
$port = 3306;
|
||||
$username = "FSST";
|
||||
$password = "L9wUNZZ9Qkbt";
|
||||
$db = "FSST";
|
||||
|
||||
$conn = mysqli_connect($servername, $username, $password, $db, $port);
|
||||
if (!$conn)
|
||||
{
|
||||
http_response_code(500);
|
||||
die("Datenbankfehler");
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
$activeCategory = isset($_GET['category']) ? $_GET['category'] : 'all';
|
||||
?>
|
||||
|
||||
<?php
|
||||
$categories = [
|
||||
'iphone' => ['id' => 20, 'label' => 'iPhone'],
|
||||
'ipad' => ['id' => 21, 'label' => 'iPad'],
|
||||
'macbook' => ['id' => 22, 'label' => 'MacBook'],
|
||||
'airpods' => ['id' => 23, 'label' => 'AirPods'],
|
||||
'accessories' => ['id' => 24, 'label' => 'Accessories'],
|
||||
];
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php foreach ($categories as $key => $cat): ?>
|
||||
|
||||
<?php if ($activeCategory === 'all' || $activeCategory === $key): ?>
|
||||
|
||||
<?php
|
||||
$stmt = $conn->prepare("
|
||||
SELECT productID, model, description, imagePath
|
||||
FROM products
|
||||
WHERE categoryID = ?
|
||||
");
|
||||
|
||||
$stmt->bind_param("i", $cat['id']); // i = integer
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
?>
|
||||
|
||||
<?php if ($result->num_rows > 0): ?>
|
||||
<section class="product-section">
|
||||
<h2><?= htmlspecialchars($cat['label']) ?></h2>
|
||||
|
||||
<div class="product-scroll">
|
||||
<?php while ($product = $result->fetch_assoc()): ?>
|
||||
<?php $productId = (int)$product['productID']; ?>
|
||||
<a class="product-card" href="productpage.php?id=<?= $productId ?>">
|
||||
<img
|
||||
src="<?= isset($product['imagePath']) ? $product['imagePath'] : 'assets/images/placeholder.png' ?>"
|
||||
alt="<?= htmlspecialchars($product['model']) ?>">
|
||||
|
||||
<div class="product-card__content">
|
||||
<h3><?= htmlspecialchars($product['model']) ?></h3>
|
||||
<p><?= htmlspecialchars($product['description']) ?></p>
|
||||
</div>
|
||||
</a>
|
||||
<?php endwhile; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $stmt->close(); ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="assets/css/compcard.css">
|
||||
</head>
|
||||
|
||||
<?php include 'footer.php'; ?>
|
||||
Loading…
Reference in New Issue
Block a user