added delete function to th application
This commit is contained in:
parent
204e212fb8
commit
a19e40f205
7 changed files with 74 additions and 10 deletions
12
controllers/delete.php
Normal file
12
controllers/delete.php
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
$heading = "Delete";
|
||||||
|
$username = "MatheApp";
|
||||||
|
$password = "password";
|
||||||
|
$config = require('config.php');
|
||||||
|
$db = new Database($config['database'], $username, $password);
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
$db->query("DELETE FROM user WHERE username = :user", ["user" => $_SESSION['username']]);
|
||||||
|
session_destroy();
|
||||||
|
header("Location: /");
|
||||||
|
exit;
|
||||||
|
|
@ -14,8 +14,11 @@ if (isset($_POST["submit"])) {
|
||||||
if (password_verify($_POST['password'], $stmt["password"])) {
|
if (password_verify($_POST['password'], $stmt["password"])) {
|
||||||
session_start();
|
session_start();
|
||||||
$_SESSION["username"] = $stmt['username'];
|
$_SESSION["username"] = $stmt['username'];
|
||||||
//require "views/profile.php";
|
$_SESSION["level"] = $stmt['level'];
|
||||||
//urlIs("/profile");
|
$_SESSION["xp"] = $stmt['xp'];
|
||||||
|
$_SESSION["coins"] = $stmt['coins'];
|
||||||
|
$_SESSION["lesson_count"] = $stmt['lesson_count'];
|
||||||
|
|
||||||
header("Location: /profile");
|
header("Location: /profile");
|
||||||
} else {
|
} else {
|
||||||
echo "Anmeldung fehlgeschlagen!";
|
echo "Anmeldung fehlgeschlagen!";
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
$heading = "profile";
|
$heading = "profile";
|
||||||
|
$username = "MatheApp";
|
||||||
|
$password = "password";
|
||||||
|
$config = require('config.php');
|
||||||
|
$db = new Database($config['database'], $username, $password);
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
if(!isset($_SESSION["username"])){
|
if(!isset($_SESSION["username"])){
|
||||||
header("Location: /");
|
header("Location: /");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
require "views/profile.view.php";
|
require "views/profile.view.php";
|
||||||
|
|
|
||||||
|
|
@ -16,17 +16,19 @@
|
||||||
//Username ist frei
|
//Username ist frei
|
||||||
//User anlegen
|
//User anlegen
|
||||||
$hash = password_hash($_POST["Passwort"], PASSWORD_BCRYPT);
|
$hash = password_hash($_POST["Passwort"], PASSWORD_BCRYPT);
|
||||||
$db->query("INSERT INTO user (username, vorname, nachname, email, password, level, xp, coins) VALUES (
|
$db->query("INSERT INTO user (username, vorname, nachname, email, password, lesson_count, level, xp, coins) VALUES (
|
||||||
:username, :vorname, :nachname, :email, :password, :level, :xp, :coins )", [
|
:username, :vorname, :nachname, :email, :password, :lesson_count, :level, :xp, :coins )", [
|
||||||
'username' => $_POST['Username'],
|
'username' => $_POST['Username'],
|
||||||
'vorname' => $_POST['Vorname'],
|
'vorname' => $_POST['Vorname'],
|
||||||
'nachname' => $_POST['Nachname'],
|
'nachname' => $_POST['Nachname'],
|
||||||
'email' => $_POST['Email-Adresse'],
|
'email' => $_POST['Email-Adresse'],
|
||||||
'password' => $hash,
|
'password' => $hash,
|
||||||
|
'lesson_count' => 0,
|
||||||
'level' => 1,
|
'level' => 1,
|
||||||
'xp' => 0,
|
'xp' => 0,
|
||||||
'coins' => 0
|
'coins' => 0
|
||||||
]);
|
]);
|
||||||
|
header("Location: /login");
|
||||||
} else {
|
} else {
|
||||||
echo "Die Passwörter stimmen nicht überein";
|
echo "Die Passwörter stimmen nicht überein";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,6 @@ return[
|
||||||
'/login' => 'controllers/login.php',
|
'/login' => 'controllers/login.php',
|
||||||
'/register' => 'controllers/register.php',
|
'/register' => 'controllers/register.php',
|
||||||
'/profile' => 'controllers/profile.php',
|
'/profile' => 'controllers/profile.php',
|
||||||
'/logout' => 'controllers/logout.php'
|
'/logout' => 'controllers/logout.php',
|
||||||
|
'/delete' => 'controllers/delete.php'
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,49 @@
|
||||||
<?php require('partials/nav.php') ?>
|
<?php require('partials/nav.php') ?>
|
||||||
|
|
||||||
<div class="flex min-h-full items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
|
<div class="flex min-h-full items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
|
||||||
<div class="w-full max-w-md space-y-8 nes-container">
|
<div class="flex-col">
|
||||||
<h1>Dieses ist die Profile Page</h1>
|
<div class="w-1000 space-y-8 nes-container">
|
||||||
<a href="/logout" class="<?= urlIs("/logout") ?> nes-btn">Abmelden</a>
|
<section class="message-list flex-auto">
|
||||||
</div>
|
<section class="message -left flex space-x-10">
|
||||||
|
<i class="nes-bcrikko mr-10"></i>
|
||||||
|
<div class="nes-balloon from-left mx-10">
|
||||||
|
<p>Hallo <?= $_SESSION['username'] ?> schön das du da bist.</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
<div class="nes-container flex-col justife-center items-center space-y-4">
|
||||||
|
<div class="text-center">
|
||||||
|
<h1>Was möchtest du tun?</h1>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-evenly items-center">
|
||||||
|
<a href="/learn" class="<?= urlIs("/learn") ?> nes-btn">Lernen</a>
|
||||||
|
<a href="/game" class="<?= urlIs("/game") ?> nes-btn">Üben</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="nes-container with-title flex-col mt-10 space-y-4">
|
||||||
|
<span class="title">Dein Fortschritt <?php $_SESSION['xp'] ?> </span>
|
||||||
|
|
||||||
|
<span>Du bist aktuell Level: <?php echo $_SESSION['level'] ?> </span>
|
||||||
|
<br>
|
||||||
|
<span>Deine Erfahrungspunkte</span>
|
||||||
|
<progress class="nes-progress is-primary" value="<?php echo $_SESSION['xp'] ?>" max="150">Erfahrung</progress>
|
||||||
|
<span>Dein aktueller Lernfortschritt</span>
|
||||||
|
<progress class="nes-progress is-success" value="<?php echo $_SESSION['lesson_count'] ?>" max="10">Absolvierte Lektionen</progress>
|
||||||
|
<div class="flex flex-rows justify-center">
|
||||||
|
<div>
|
||||||
|
<span><i class="nes-icon coin is-medium"></i></span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p><?php echo $_SESSION['coins'] ?></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="nes-container mt-10">
|
||||||
|
<div>
|
||||||
|
<a href="/delete" class="nes-btn is-error">Account löschen</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php require('partials/footer.php') ?>
|
<?php require('partials/footer.php') ?>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<?php require('partials/nav.php') ?>
|
<?php require('partials/nav.php') ?>
|
||||||
<div class="flex min-h-full items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
|
<div class="flex min-h-full items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
|
||||||
<div class="w-full max-w-md space-y-8 nes-container">
|
<div class="w-full max-w-md space-y-8 nes-container">
|
||||||
<form action="/login" method="POST">
|
<form action="/register" method="POST">
|
||||||
|
|
||||||
<div class="nes-field">
|
<div class="nes-field">
|
||||||
<label for="username">Username</label>
|
<label for="username">Username</label>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue