diff --git a/src/Application/Login.php b/src/Application/Login.php index 0de24c5..b353f10 100644 --- a/src/Application/Login.php +++ b/src/Application/Login.php @@ -24,11 +24,23 @@ class Login { }); $app->post('/login', function ($request, $response, $args) { // Render index view + $post = $request->getParsedBody(); - if(isset($_POST["username"])){ - echo "Jouw naam is: " . $_POST["username"] . " en je wachtwoord is: " . $_POST["password"] . "
\n"; + $user = $this->db->gebruikers("username = ?", $post["username"]); + if ($user->count("*") === 0){ + echo "Onjuiste gebruikersnaam of wachtwoord"; + } else { + if(password_verify($post["password"], $user["password"])){ + session_start(); + $_SESSION["user"] = [ + "uuid" => $user["uuid"], + "username" => $user["username"] + ]; + }else{ + echo "fout"; + } } - $newResponse = $response->withHeader('Location', 'index.php'); + $newResponse = $response->withHeader('Location', ''); return $this->renderer->render($newResponse, 'login.phtml', $args); }); } diff --git a/templates/login.phtml b/templates/login.phtml index 595a861..7394117 100644 --- a/templates/login.phtml +++ b/templates/login.phtml @@ -29,6 +29,9 @@ body{ color: #ff6000; } + .footer{ + text-align: center; + }
@@ -48,7 +51,7 @@