This commit is contained in:
Illia Hromovoi 2025-06-18 10:52:17 +02:00
commit 47e6d11fad
5 changed files with 118 additions and 2 deletions

View File

@ -6,5 +6,21 @@
font-size: var(--font-size-text);
border-radius: 3px;
text-decoration: none;
cursor: pointer;
}
.btn-user {
border-radius: 9999px;
color: var(--brand-primary);
background-color: var(--brand-white);
display: flex;
flex-direction: row;
justify-content: center;
justify-items: center;
align-items: center;
width: fit-content;
aspect-ratio: 1/1;
}
.btn-user > span {
font-size: 28px;
}

View File

@ -0,0 +1,56 @@
<?php
namespace Blog\Controller;
use Blog\Model\AdminModel;
class AdminController
{
protected $view;
private $db;
private $validData = array();
private $errors = array();
private $labels = array("name" => "Name*", "preis" => "Preis*", "dauer" => "Dauer*", "rabatt" => "Rabatt", "kategorie" => "Kategorie", "beschreibung" => "Beschreibung");
public function __construct($view)
{
$this->db = new AdminModel();
$this->view = $view;
}
public function showForm()
{
$this->view->setVars([
'labels' => $this->labels,
'validData' => $this->validData,
'errors' => $this->errors
]);
}
public function showConfirmation()
{
}
public function validateForm(){
foreach ($this->labels as $index => $value) {
if (!isset($_POST[$index]) || empty($_POST[$index])) {
$this->errors[$index] = "Bitte " . $value . " angeben";
} else {
$this->validData[$index] = $_POST[$index];
}
}
if (count($this->errors) > 0) {
$this->view->setDoMethodName("showContactForm");
$this->showContactForm();
} else {
if ($this->db->writeContactData($this->validData)) {
$this->view->setDoMethodName("showConfirmation");
$this->showConfirmation();
}
}
}
}
?>

12
Model/AdminModel.php Normal file
View File

@ -0,0 +1,12 @@
<?php
namespace Blog\Model;
use PDOException;
class AdminModel extends Database
{
public function writeContactData($values)
{
}
}

View File

@ -0,0 +1,30 @@
<?php
include dirname(__DIR__).'/header.phtml';
?>
<h2>Neuer Kurs</h2>
<form method="post">
<?php foreach ($labels as $index => $value) {
echo '<label for="' . $index . '">' . $value . '</label>';
if ($index == "beschreibung") {
echo "<textarea id=\"$index\" name=\"$index\" >";
if (isset($validData[$index])) { echo $validData[$index]; }
echo "</textarea><br>";
} else {
echo '<input type="text" name="' . $index . '" value="' . (isset($validData[$index]) ? $validData[$index] : '') . '"><br>';
}
if (isset($errors[$index])) {
echo '<label class="errorMsg">' . $errors[$index] . '</label><br>';
}
}
?>
<input type="hidden" name="controller" value="contact">
<input type="hidden" name="do" value="validateForm">
<input type="submit" name="submit" value="Absenden"></form>
<?php include dirname(__DIR__).'/footer.phtml'; ?>

View File

@ -8,6 +8,8 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Source+Serif+4:ital,opsz,wght@0,8..60,200..900;1,8..60,200..900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">
<link href="CSS/style.css" rel="stylesheet" type="text/css" />
</head>
@ -17,6 +19,7 @@
<div class="d-flex-between">
<h3 class="logo">bib<span>course</span></h3>
<div id="metanavi">
<a class="btn btn-user" href="?controller=Admin&do=showForm"><span class="material-icons">person</span></a>
<a class="btn btn-register" href="?controller=User&do=showUserForm">Registration</a>
</div>
</div>
@ -26,7 +29,6 @@
<li><a href="#">Projekte</a></li>
<li><a href="#">Workshops</a></li>
<li><a href="?controller=Contact&do=showContactForm">Kontakt</a></li>
</ul>
</nav>
</div>