added login, logout and registration sites and functionality as well as an protected profile page
This commit is contained in:
parent
cbebac47fa
commit
5b3f5a1123
12 changed files with 163 additions and 28 deletions
|
|
@ -1,3 +1,28 @@
|
|||
<?php
|
||||
$heading = "Login";
|
||||
require "views/login.view.php";
|
||||
$heading = "Login";
|
||||
$username = "MatheApp";
|
||||
$password = "password";
|
||||
$config = require('config.php');
|
||||
$db = new Database($config['database'], $username, $password);
|
||||
|
||||
if (isset($_POST["submit"])) {
|
||||
$stmt = $db->query("SELECT * FROM user WHERE username = :user", ['user' => $_POST["username"]])->get();
|
||||
$count = sizeof($stmt);
|
||||
if ($count == 1) {
|
||||
$stmt = $stmt[0];;
|
||||
|
||||
if (password_verify($_POST['password'], $stmt["password"])) {
|
||||
session_start();
|
||||
$_SESSION["username"] = $stmt['username'];
|
||||
//require "views/profile.php";
|
||||
//urlIs("/profile");
|
||||
header("Location: /profile");
|
||||
} else {
|
||||
echo "Anmeldung fehlgeschlagen!";
|
||||
}
|
||||
} else {
|
||||
echo "Anmeldung fehlgeschlagen!";
|
||||
}
|
||||
}
|
||||
|
||||
require "views/login.view.php";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue