M4 A1 3 wunschgericht.php erstellt und verlinkt; style.css erstellt und eingebunden

This commit is contained in:
S170H
2023-12-01 18:25:28 +01:00
parent b8d937d110
commit 644248d1ff
5 changed files with 174 additions and 121 deletions

1
M4/.idea/php.xml generated
View File

@@ -10,6 +10,7 @@
<option name="highlightLevel" value="WARNING" />
<option name="transferred" value="true" />
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.0" />
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>

View File

@@ -130,99 +130,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
<head>
<meta charset="UTF-8">
<title>Ihre E-Mensa</title>
<style>
* {
font-family: Arial;
}
.grid {
display: grid;
grid-template-columns: 200px auto 200px;
}
img {
width: 100%;
height: auto;
}
.speisen {
border: solid;
border-collapse: collapse;
}
.speisen td {
border: solid;
border-collapse: collapse;
border-radius: 4px;
padding: 5px;
width: auto;
}
.speisen td:not(:first-of-type) {
text-align: center;
}
p {
text-align: justify;
}
.zahlen {
list-style-type: none;
display: grid;
grid-template-columns: auto auto auto;
gap: 10px;
}
.zahlen p {
text-align: center;
font-weight: bold;
}
.formular {
display: grid;
grid-template-columns: auto auto auto;
justify-content: start;
gap: 10px;
}
.wichtig {
text-align: center;
}
.wichtigListe {
display: inline-block;
text-align: left;
}
.freude {
text-align: center;
}
footer {
border-top: 1px solid;
}
.fusszeile {
padding-top: 20px;
padding-bottom: 20px;
margin-left: auto;
margin-right: auto;
border: none;
}
.fusszeile td:first-child {
border-left: none;
padding-left: 20px;
padding-right: 20px;
}
.fusszeile td {
border-left: 3px solid;
padding-left: 20px;
padding-right: 20px;
}
</style>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="grid">
@@ -304,6 +212,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
echo $verwendete_allergene_string;
?>
<h1>Für Sie nichts dabei? <a href="/Werbeseite/wunschgericht.php">Wunschgericht erfassen</a></h1>
<h1 id="zahlen">E-Mensa in Zahlen</h1>
<div class="zahlen">

90
M4/Werbeseite/style.css Normal file
View File

@@ -0,0 +1,90 @@
* {
font-family: Arial;
}
.grid {
display: grid;
grid-template-columns: 200px auto 200px;
}
img {
width: 100%;
height: auto;
}
.speisen {
border: solid;
border-collapse: collapse;
}
.speisen td {
border: solid;
border-collapse: collapse;
border-radius: 4px;
padding: 5px;
width: auto;
}
.speisen td:not(:first-of-type) {
text-align: center;
}
p {
text-align: justify;
}
.zahlen {
list-style-type: none;
display: grid;
grid-template-columns: auto auto auto;
gap: 10px;
}
.zahlen p {
text-align: center;
font-weight: bold;
}
.formular {
display: grid;
grid-template-columns: auto auto auto;
justify-content: start;
gap: 10px;
}
.wichtig {
text-align: center;
}
.wichtigListe {
display: inline-block;
text-align: left;
}
.freude {
text-align: center;
}
footer {
border-top: 1px solid;
}
.fusszeile {
padding-top: 20px;
padding-bottom: 20px;
margin-left: auto;
margin-right: auto;
border: none;
}
.fusszeile td:first-child {
border-left: none;
padding-left: 20px;
padding-right: 20px;
}
.fusszeile td {
border-left: 3px solid;
padding-left: 20px;
padding-right: 20px;
}

View File

@@ -0,0 +1,80 @@
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$gericht_name = $_POST['gericht_name'];
$gericht_beschreibung = $_POST['gericht_beschreibung'];
$ersteller_name = $_POST['ersteller_name'];
$ersteller_email = $_POST['ersteller_email'];
// Datenbankverbindung
$link = mysqli_connect(
"127.0.0.1",
"root",
"wm#32",
"emensawerbeseite"
);
if (!$link) {
echo "Verbindung fehlgeschlagen: ", mysqli_connect_error();
exit();
}
// Einfügen in die Datenbank
$sql = "INSERT INTO wunschgericht (name, beschreibung) VALUES ('" . mysqli_real_escape_string($link, $gericht_name) . "', '" . mysqli_real_escape_string($link, $gericht_beschreibung) . "')";
$result = mysqli_query($link, $sql);
if ($result) {
echo "Ihr Wunschgericht wurde erfolgreich gespeichert!";
} else {
echo "Es gab einen Fehler: " . mysqli_error($link);
}
mysqli_close($link);
}
?>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<title>Ihre E-Mensa</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="grid">
<div>
<img src="fh-logo.jpg" alt="FH-Logo">
</div>
<div>
<a href="index.php#ankündigung">Ankündigung</a>
<a href="index.php#speisen">Speisen</a>
<a href="index.php#zahlen">Zahlen</a>
<a href="index.php#kontakt">Kontakt</a>
<a href="index.php#wichtig">Wichtig für uns</a>
</div>
</div>
<hr>
<form method="post" action="wunschgericht.php">
<div class="formular">
<label for="gericht_name">Name des Gerichts:</label>
<input type="text" name="gericht_name" id="gericht_name" required>
<br>
<label for="gericht_beschreibung">Beschreibung des Gerichts:</label>
<textarea name="gericht_beschreibung" id="gericht_beschreibung" required></textarea>
<br>
<label for="ersteller_name">Ihr Name:</label>
<input type="text" name="ersteller_name" id="ersteller_name">
<br>
<label for="ersteller_email">Ihre E-Mail Adresse:</label>
<input type="text" name="ersteller_email" id="ersteller_email" required>
<input type="submit" value="Wunsch abschicken">
</div>
</form>
</body>
<footer>
<table class="fusszeile">
<tr>
<td>(c) E-Mensa GmbH</td>
<td>Şafak Hazinedar & Robert Joel</td>
<td><a href="">Impressum</a></td>
</tr>
</table>
</footer>
</html>

View File

@@ -1,28 +0,0 @@
<?php
$link=mysqli_connect(
"127.0.0.1", // Host der Datenbank
"root", // Benutzername zur Anmeldung
"wm#32", // Passwort
"emensawerbeseite" // Auswahl der Datenbanken (bzw. des Schemas)
);
if (!$link) {
echo "Verbindung fehlgeschlagen: ", mysqli_connect_error();
exit();
}
$sql = "SELECT erfasst_am FROM gericht ";
$result = mysqli_query($link, $sql);
if (!$result) {
echo "Fehler während der Abfrage: ", mysqli_error($link);
exit();
}
$tabelle = "<table>";
while ($row = mysqli_fetch_assoc($result)) {
$tabelle .= "<tr><td>". $row['erfasst_am']. "</td></tr>";
}
$tabelle .= "</table>";
echo $tabelle;
mysqli_free_result($result);
mysqli_close($link);