Initiale Version

This commit is contained in:
Jan Unger
2016-08-16 21:20:53 +02:00
commit 88cf71d772
10930 changed files with 1708903 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
<?php
session_start();
if (!isset($_SESSION['warenkorb'])) {
$_SESSION['warenkorb'] = [];
}
function holeSortiment()
{
return [
1 => 'Moderne Webseiten entwickeln',
2 => 'PHP 7 und MySQL - Das umfassende Handbuch',
3 => 'Der große Fotokurs - Richtig fotografieren lernen'
];
}
function zaehleWarenkorb()
{
$ergebnis = 0;
foreach ($_SESSION['warenkorb'] as $artikelId => $anzahl) {
$ergebnis += $anzahl;
}
return $ergebnis;
}

View File

@@ -0,0 +1,46 @@
<?php
require __DIR__ . '/_applikation.php';
if (isset($_GET['hinzufuegen'])) {
$artikelId = $_GET['hinzufuegen'];
if (!isset($_SESSION['warenkorb'][$artikelId])) {
$_SESSION['warenkorb'][$artikelId] = 0;
}
$_SESSION['warenkorb'][$artikelId]++;
header('Location: index.php');
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Artikelliste</title>
</head>
<body>
<p>
<?php if (zaehleWarenkorb() == 0): ?>
Ihr Warenkorb ist leer.
<?php else: ?>
Ihr Warenkorb enthält <?= htmlspecialchars(zaehleWarenkorb()); ?> Artikel.
<?php endif; ?>
- <a href="warenkorb.php">Warenkorb anzeigen</a>
</p>
<h1>Unser Angebot</h1>
<table>
<?php foreach (holeSortiment() as $artikelId => $artikel) : ?>
<tr>
<td><?= htmlspecialchars($artikel); ?></td>
<td><a href="index.php?hinzufuegen=<?= htmlspecialchars($artikelId); ?>">In den Warenkorb</a></td>
</tr>
<?php endforeach; ?>
</table>
</body>
</html>

View File

@@ -0,0 +1,39 @@
<?php
require __DIR__ . '/_applikation.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Warenkorb</title>
</head>
<body>
<h1>Ihr Warenkorb</h1>
<form action="warenkorb.php" method="post">
<table>
<tr>
<th>Bezeichnung</th>
<th>Anzahl</th>
</tr>
<tr>
<td>Moderne Webseiten entwickeln</td>
<td>
<input type="text"
name="artikel[1]"
value="1"/>
</td>
</tr>
</table>
<p>
<button type="submit" name="aktualisieren">Aktualisieren</button>
</p>
</form>
<p><a href="index.php">Zur Produktauswahl</a></p>
</body>
</html>

View File

@@ -0,0 +1,26 @@
<?php
session_start();
if (!isset($_SESSION['warenkorb'])) {
$_SESSION['warenkorb'] = [];
}
function holeSortiment()
{
return [
1 => 'Moderne Webseiten entwickeln',
2 => 'PHP 7 und MySQL - Das umfassende Handbuch',
3 => 'Der große Fotokurs - Richtig fotografieren lernen'
];
}
function zaehleWarenkorb()
{
$ergebnis = 0;
foreach ($_SESSION['warenkorb'] as $artikelId => $anzahl) {
$ergebnis += $anzahl;
}
return $ergebnis;
}

View File

@@ -0,0 +1,46 @@
<?php
require __DIR__ . '/_applikation.php';
if (isset($_GET['hinzufuegen'])) {
$artikelId = $_GET['hinzufuegen'];
if (!isset($_SESSION['warenkorb'][$artikelId])) {
$_SESSION['warenkorb'][$artikelId] = 0;
}
$_SESSION['warenkorb'][$artikelId]++;
header('Location: index.php');
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Artikelliste</title>
</head>
<body>
<p>
<?php if (zaehleWarenkorb() == 0): ?>
Ihr Warenkorb ist leer.
<?php else: ?>
Ihr Warenkorb enthält <?= htmlspecialchars(zaehleWarenkorb()); ?> Artikel.
<?php endif; ?>
- <a href="warenkorb.php">Warenkorb anzeigen</a>
</p>
<h1>Unser Angebot</h1>
<table>
<?php foreach (holeSortiment() as $artikelId => $artikel) : ?>
<tr>
<td><?= htmlspecialchars($artikel); ?></td>
<td><a href="index.php?hinzufuegen=<?= htmlspecialchars($artikelId); ?>">In den Warenkorb</a></td>
</tr>
<?php endforeach; ?>
</table>
</body>
</html>

View File

@@ -0,0 +1,56 @@
<?php
require __DIR__ . '/_applikation.php';
$sortiment = holeSortiment();
if (isset($_POST['aktualisieren'])) {
foreach ($_POST['artikel'] as $artikelId => $anzahl) {
if ($anzahl == 0) {
unset($_SESSION['warenkorb'][$artikelId]);
} else {
$_SESSION['warenkorb'][$artikelId] = $anzahl;
}
}
header('Location: warenkorb.php');
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Warenkorb</title>
</head>
<body>
<h1>Ihr Warenkorb</h1>
<form action="warenkorb.php" method="post">
<table>
<tr>
<th>Bezeichnung</th>
<th>Anzahl</th>
</tr>
<?php foreach ($_SESSION['warenkorb'] as $artikelId => $anzahl) : ?>
<tr>
<td><?= htmlspecialchars($sortiment[$artikelId]); ?></td>
<td>
<input type="text"
name="artikel[<?= htmlspecialchars($artikelId); ?>]"
value="<?= htmlspecialchars($anzahl); ?>"/>
</td>
</tr>
<?php endforeach; ?>
</table>
<p>
<button type="submit" name="aktualisieren">Aktualisieren</button>
</p>
</form>
<p><a href="index.php">Zur Produktauswahl</a></p>
</body>
</html>