Erstellung des Benutzerregistrierungssystem

This commit is contained in:
Illia Hromovoi 2025-06-18 10:50:44 +02:00
parent 114f8ead52
commit 711b928fa5
7 changed files with 42 additions and 17 deletions

View File

@ -6,4 +6,5 @@
font-size: var(--font-size-text); font-size: var(--font-size-text);
border-radius: 3px; border-radius: 3px;
text-decoration: none; text-decoration: none;
cursor: pointer;
} }

View File

@ -38,7 +38,7 @@ h2 {
} }
main { main {
margin-top: 135px; margin-top: 190px;
padding: 10px; padding: 10px;
} }
@ -104,10 +104,6 @@ label.errorMsg {
color: orange; color: orange;
} }
input {
width: 300px;
}
input[type="submit"] { input[type="submit"] {
width: 100px; width: 100px;
margin-left: 330px; margin-left: 330px;

View File

@ -9,7 +9,6 @@ class UserController{
private $db; private $db;
private $validData = array(); private $validData = array();
private $errors = array(); private $errors = array();
private $labels = array("name" => "Name", "lastname"=> "Nachname", "email" => "E-Mail-Adresse", "password" => "Password", "role" => "Role");
public function __construct($view){ public function __construct($view){
$this->db = new UserModel(); $this->db = new UserModel();
@ -24,9 +23,17 @@ class UserController{
} }
public function showUserLoginForm(){
}
public function register(){ public function register(){
$this->db->createUser($this->labels); $this->db->createUser($_POST);
$this->view->setDoMethodName("showUserConfirmation"); $this->view->setDoMethodName("showUserConfirmation");
$this->showUserConfirmation(); $this->showUserConfirmation();
} }
public function login(){
}
} }

View File

@ -11,8 +11,7 @@ class UserModel extends Database
/** /**
* @throws RandomException * @throws RandomException
*/ */
public function createUser($values) public function createUser($values){
{
$salt = bin2hex(random_bytes(16)); $salt = bin2hex(random_bytes(16));
@ -25,8 +24,6 @@ class UserModel extends Database
$sql = "INSERT INTO user (`id`, `name`,`vorname`,`email`,`passwort`,`salt`,`role`) $sql = "INSERT INTO user (`id`, `name`,`vorname`,`email`,`passwort`,`salt`,`role`)
VALUES (:guid, :name, :firstname, :email, :password, :salt, :role)"; VALUES (:guid, :name, :firstname, :email, :password, :salt, :role)";
var_dump($values);
try { try {
$sth = $pdo->prepare($sql); $sth = $pdo->prepare($sql);
$sth->execute([ $sth->execute([

View File

@ -2,7 +2,7 @@
include dirname(__DIR__).'/header.phtml'; include dirname(__DIR__).'/header.phtml';
?> ?>
<h1>Der Benutzer wurde erfolgreich erstellt</h1> <h1>Sie haben sich erfolgreich registriert</h1>

View File

@ -2,7 +2,7 @@
include dirname(__DIR__).'/header.phtml'; include dirname(__DIR__).'/header.phtml';
?> ?>
<h1>Benutzer</h1> <h1>Benutzer erstellen</h1>
<form method="post"> <form method="post">
<h2>Registrieren</h2> <h2>Registrieren</h2>
@ -14,10 +14,10 @@
<input type="text" name="lastname" id="reg_lastname" required> <input type="text" name="lastname" id="reg_lastname" required>
<label for="reg_email">Email:</label> <label for="reg_email">Email:</label>
<input type="text" name="email" id="reg_email" required> <input type="email" name="email" id="reg_email" required>
<label for="reg_password">Passwort:</label> <label for="reg_password">Passwort:</label>
<input type="text" name="password" id="reg_password" required> <input type="password" name="password" id="reg_password" required>
<p>Wähle deine Rolle:</p> <p>Wähle deine Rolle:</p>
<label> <label>
@ -29,10 +29,11 @@
<input type="hidden" name="controller" value="user"> <input type="hidden" name="controller" value="user">
<input type="hidden" name="do" value="register"> <input type="hidden" name="do" value="register">
<button type="submit" style="display: block">Registrieren</button> <button type="submit" class="btn" style="display: block">Registrieren</button>
</form> </form>
<a href="?controller=User&do=showUserLoginForm">Haben Sie schon ein Benutzer Konto?</a>
<?php <?php
include dirname(__DIR__).'/footer.phtml'; include dirname(__DIR__).'/footer.phtml';
?> ?>

View File

@ -0,0 +1,23 @@
<?php
include dirname(__DIR__).'/header.phtml';
?>
<h1>Als Benutzer anmelden</h1>
<form method="post">
<label for="reg_email">Email:</label>
<input type="email" name="email" id="reg_email" required>
<label for="reg_password">Passwort:</label>
<input type="password" name="password" id="reg_password" required>
<input type="hidden" name="controller" value="user">
<input type="hidden" name="do" value="register">
<button type="submit" style="display: block">Login</button>
</form>
<?php
include dirname(__DIR__).'/footer.phtml';
?>