This commit is contained in:
Karol Bielski 2025-06-16 11:36:17 +02:00
commit 9e5b874fe0
9 changed files with 123 additions and 30 deletions

View File

@ -35,29 +35,4 @@ nav li a {
nav li a:hover {
background-color: orange;
}
#metanavi {
color: #4d4d4d;
font-weight: bold;
margin-bottom: 5px;
}
#metanavi a {
background: #09add0;
border: none;
width: 100px;
margin: 0 5px 0 5px;
float: right;
padding: 2px;
border-radius: 5px;
color:#fff;
cursor:pointer;
font-size: 12px;
text-decoration: none;
text-align: center;
}
#metanavi a:hover {
background: orange;
}

9
CSS/Element/button.css Normal file
View File

@ -0,0 +1,9 @@
.btn{
background: var(--brand-primary);
color: var(--brand-white);
padding: 5px 10px;
font-weight: var(--font-weight-semibold);
font-size: var(--font-size-text);
border-radius: 3px;
text-decoration: none;
}

View File

@ -1,7 +1,8 @@
@import url(variables.css);
@import url(Block/header.css);
@import url(Block/footer.css);
@import url(Element/logo.scss);
@import url(Element/logo.css);
@import url(Element/button.css);
*, *:before, *:after {
-moz-box-sizing: border-box;

View File

@ -0,0 +1,27 @@
<?php
namespace Blog\Controller;
use Blog\Model\UserModel;
class UserController{
private $view;
private $db;
private $validData = array();
private $errors = array();
private $labels = array("name" => "Name", "email" => "E-Mail-Adresse", "content" => "Nachricht");
public function __construct($view){
$this->db = new UserModel();
$this->view = $view;
}
public function showUserForm(){
}
public function register(){
$this->db->createUser($this->labels);
}
}

47
Model/UserModel.php Normal file
View File

@ -0,0 +1,47 @@
<?php
namespace Blog\Model;
use Blog\Model\Database;
use PDOException;
use Random\RandomException;
class UserModel extends Database
{
/**
* @throws RandomException
*/
public function createUser($values)
{
$salt = bin2hex(random_bytes(16));
$hash = hash('sha256', $values["password"] . $salt);
$guid = $this->createUUID();
$pdo = $this->linkDB();
$sql = "INSERT INTO users (`id`,`vorname`,`name`,`email`,`passwort`,`salt`,`role`)
VALUES (:guid, :name, :lastname, :email, :password, :salt, :role)";
try {
$sth = $pdo->prepare($sql);
$sth->execute(array
(":guid" => $guid,
(":name") => $values["name"],
":lastname" => $values["lastname"],
":email" => $values["email"],
":password" => $hash,
":salt" => $salt,
":role" => $values["role"]
));
} catch (PDOException $e) {
new \Blog\Library\ErrorMsg("Fehler beim Schreiben der Daten.", $e);
die;
}
return true;
}
}

View File

@ -0,0 +1,34 @@
<?php
include dirname(__DIR__).'/header.phtml';
?>
<h1>Benutzer</h1>
<form method="post" action="register">
<h2>Registrieren</h2>
<label for="reg_name">Vorname:</label>
<input type="text" name="name" id="reg_name" required>
<label for="reg_lastname">Nachname:</label>
<input type="text" name="lastname" id="reg_lastname" required>
<label for="reg_email">Email:</label>
<input type="text" name="email" id="reg_email" required>
<label for="reg_password">Passwort:</label>
<input type="text" name="password" id="reg_password" required>
<p>Wähle deine Rolle:</p>
<label>
<input type="radio" name="role" value="course_instructor" required> Student
</label>
<label>
<input type="radio" name="role" value="member"> Lehrer
</label>
</form>
<?php
include dirname(__DIR__).'/footer.phtml';
?>

View File

@ -3,7 +3,7 @@
<footer>
<div id="wrapper">
<div class="d-flex-between">
<h3 class="logo">bib<span>course</span></h1>
<h3 class="logo">bib<span>course</span></h3>
</div>
</div>
</footer>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html lang="de">
<head>
<title>VR Contact</title>
@ -15,9 +15,9 @@
<header>
<div id="wrapper">
<div class="d-flex-between">
<h3 class="logo">bib<span>course</span></h1>
<h3 class="logo">bib<span>course</span></h3>
<div id="metanavi">
<a href="#">Anmelden</a>
<a class="btn btn-register" href="?controller=User&do=showUserForm">Registration</a>
</div>
</div>
<nav>