This commit is contained in:
the_kellner 2018-06-17 18:12:29 +02:00
commit 7fb652f323
8 changed files with 57 additions and 43 deletions

BIN
docs/dashboard-drawing.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
docs/er-modell.pdf Normal file

Binary file not shown.

1
docs/er-modell.xml Normal file
View File

@ -0,0 +1 @@
<mxfile userAgent="Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36" version="8.8.1" editor="www.draw.io" type="device"><diagram id="63ee0f3d-929e-82aa-bd70-31e98903fd11" name="Page-1">5VtLb+M2EP41vhp86nHceDdtDwUKBGi3R61F28LKoivTa6e/vpRFyZKGUd2EeiT1IRCH4kPffDMcDpkFXe0vP+XRYferjEW6ICi+LOjnBSFhQPXfQvBcCrgfloJtnsSlCN8ET8nfwgiRkZ6SWBxbLyopU5Uc2sK1zDKxVi1ZlOfy3H5tI9P2qIdoK4DgaR2lUPpHEqtdKQ04usl/Fsl2V42Mkan5Fq2/b3N5ysx4C0I3119ZvY+qvsz7x10Uy3NDRL8s6CqXUpVP+8tKpAW0FWxlu8cXaut55yJT9zQgZYMfUXoyn64b5onGvpyeeq4guX6UKJqhBX047xIlng7Ruqg9aw5o2U7tU13C+tH0KnIlLi/ODNffq2kk5F6o/Fm/UjUI/CUvGxkS4Qr+800luAJy11CHZ2SRYcG27vyGhH4wYNiBoQCY01Hk08PCEYCFjggLA7AAREQWfypMUJcymYk2AgW7nr8atK6FP4uC/iRdvCTqa/Wefr7VlGOIGBhtBzU9D3nK16LFbRXlW6EaWoXYNpDjFuAqWS7SSCU/2pOwoWlG+E0menq16gjuqo7yjkrK6Zt2TbPtduWBrlCnq/KzQVdXBdeffpfOOdC5irLpLYFBDPCIluABVHQNsIU01UuW+Hc8NjJTT6YdM+WVTGV+7Yc+PlL9c4Qb8CDMgpvNDpgD2HwbmRbES/UYD99y/bRV9Xe+BkkXPjacEqHQtvLEc4OIk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<?php session_start(); ?>
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>

View File

@ -25,6 +25,9 @@ document.getElementById('btnCreate').addEventListener("click" , async (event) =>
method: 'post', method: 'post',
body: formData body: formData
}); });
const jsonData = await response.json();
console.log(jsonData);
} catch (e) { } catch (e) {
console.log("Abschicken der Daten fehlerhaft!"); console.log("Abschicken der Daten fehlerhaft!");
} }
@ -36,7 +39,7 @@ document.getElementById('btnLogin').addEventListener("click" , async (event) =>
// if (document.getElementById('btnLogin') === "Login") { // if (document.getElementById('btnLogin') === "Login") {
const formData = new FormData(document.getElementById('login-form')); const formData = new FormData(document.getElementById('login-form'));
try { // try {
const response = await fetch('php/signup.php', { const response = await fetch('php/signup.php', {
method: 'post', method: 'post',
body: formData body: formData
@ -47,23 +50,26 @@ document.getElementById('btnLogin').addEventListener("click" , async (event) =>
document.getElementById('login-status').innerHTML = jsonData.error.fontcolor("red"); document.getElementById('login-status').innerHTML = jsonData.error.fontcolor("red");
} else { } else {
console.log(jsonData); console.log(jsonData);
if (jsonData == 'true') { document.getElementById('login-status').innerHTML = "Eingeloggt";
document.getElementById('toggle-login').innerHTML = "Logout"; location.replace('index2.htm');
document.getElementById('btnLogin').innerHTML = "Logout"; // if (jsonData == 'true') {
document.getElementById('exampleModalLabel').innerHTML = "Logout"; // document.getElementById('toggle-login').innerHTML = "Logout";
document.getElementById('login-status').innerHTML = "Erfolgreich eingeloggt"; // document.getElementById('btnLogin').innerHTML = "Logout";
} // document.getElementById('exampleModalLabel').innerHTML = "Logout";
else { // document.getElementById('login-status').innerHTML = "Erfolgreich eingeloggt";
document.getElementById('toggle-login').innerHTML = "Login"; // }
document.getElementById('btnLogin').innerHTML = "Login"; // else {
document.getElementById('exampleModalLabel').innerHTML = "Login"; // document.getElementById('toggle-login').innerHTML = "Login";
document.getElementById('login-status').innerHTML = "Erfolgreich ausgeloggt"; // document.getElementById('btnLogin').innerHTML = "Login";
} // document.getElementById('exampleModalLabel').innerHTML = "Login";
// document.getElementById('login-status').innerHTML = "Erfolgreich ausgeloggt";
// }
// location.reload(); // location.reload();
} }
} catch (e) { // }
console.log("Login Fehler"); // catch (e) {
} // console.log("Login Fehler");
// }
// } // }
}) })

View File

@ -6,11 +6,21 @@
$pswd = ($_POST['registerPassword']); $pswd = ($_POST['registerPassword']);
$email = ($_POST['registerMail']); $email = ($_POST['registerMail']);
// if ($abfrage == "") { $search_user = $database->prepare("SELECT ID FROM user WHERE user='$name '");
$search_user->execute();
$search_result = $search_user->get_result();
if ($search_result->num_rows == 0) {
$pswd = md5($pswd);
$stmt = $database->prepare("INSERT INTO user(user, email, password) VALUES (?,?,?)"); $stmt = $database->prepare("INSERT INTO user(user, email, password) VALUES (?,?,?)");
$stmt->bind_param("sss", $name, $email, $pswd); $stmt->bind_param("sss", $name, $email, $pswd);
$stmt->execute(); $stmt->execute();
$stmt->close(); $stmt->close();
// } echo json_encode("Dein Account wurde erfolgreich erstellt!");
} else {
echo json_encode("Der Benutzername ist leider schon vergeben!");
}
?> ?>

View File

@ -1,36 +1,33 @@
<?php <?php
//<!--Login--> //<!--Login-->
session_start();
require('../dbConnect.php'); require('../dbConnect.php');
$name = ($_POST['loginName']); $name = ($_POST['loginName']);
$pswd = ($_POST['loginPassword']); $pswd = ($_POST['loginPassword']);
// $pswd = md5($pswd);
try { $stmt = $database->prepare("SELECT id FROM user WHERE '$name'=user AND password='$pswd'");
$stmt = $database->prepare("SELECT password FROM user WHERE '$name'=user");
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$row = $result->fetch_assoc();
} catch (PDOException $e) { if ($result->num_rows == 1) {
$e->getMessage(); $object = $result->fetch_object();
} $_SESSION['user'] = $object->id;
if ($pswd == $row['password']) { // header('Location: /index2.htm');
$stmt = $database->prepare("SELECT loggedin FROM user WHERE '$name'=user"); echo json_encode('Eingeloggt!');
$stmt->execute(); // $stmt = $database->prepare("SELECT loggedin FROM user WHERE '$name'=user");
$result = $stmt->get_result()->fetch_assoc(); // $stmt->execute();
if ($result['loggedin'] == 'false') { // $result = $stmt->get_result()->fetch_assoc();
$stmt = $database->prepare("UPDATE `benutzer`.`user` SET `loggedin`='true' WHERE '$name'=user"); // if ($result['loggedin'] == 'false') {
$stmt->execute(); // $stmt = $database->prepare("UPDATE `benutzer`.`user` SET `loggedin`='true' WHERE '$name'=user");
$a = "true"; // $stmt->execute();
// $a = "true";
} else { } else {
$stmt = $database->prepare("UPDATE `benutzer`.`user` SET `loggedin`='false' WHERE '$name'=user"); $a = array('error' => 'Einlogen fehlgeschlagen!');
$stmt->execute(); echo json_encode($a);
$a = "false";
} }
echo json_encode($a);
} else {
$a = array('error' => 'Einlogen fehlgeschlagen!' . $pswd . " " . $row['password']);
echo json_encode($a);
}
?> ?>

View File

@ -26,7 +26,6 @@ CREATE TABLE `kd42696_ipr-projekt`.`entries` (
`absturz` LONGTEXT NOT NULL , `absturz` LONGTEXT NOT NULL ,
`trinkspiel` LONGTEXT NOT NULL , `trinkspiel` LONGTEXT NOT NULL ,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE (`userID`),
UNIQUE (`tanID`)) ENGINE = InnoDB; UNIQUE (`tanID`)) ENGINE = InnoDB;
ALTER TABLE `entries` ADD FOREIGN KEY (`userID`) REFERENCES `user`(`ID`) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE `entries` ADD FOREIGN KEY (`userID`) REFERENCES `user`(`ID`) ON DELETE CASCADE ON UPDATE CASCADE;