-
Session User:
-
+ Herzlich Willkomen " . $_SESSION['username'] . "");
+ }
+ ?>
-
diff --git a/js/contentloader.js b/js/contentloader.js
index 4bb2df8..00d96ff 100644
--- a/js/contentloader.js
+++ b/js/contentloader.js
@@ -25,6 +25,7 @@ async function getNewUniqueLink() {
//
document.getElementById('btnCreate').addEventListener("click" , async (event) => {
+ event.preventDefault();
const formData = new FormData(document.getElementById('create-form'));
try {
const response = await fetch('php/signup.php', {
diff --git a/php/getSession.php b/php/getSession.php
deleted file mode 100644
index 1b2022b..0000000
--- a/php/getSession.php
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/php/signup.php b/php/signup.php
index 3fcc839..f7e3e13 100644
--- a/php/signup.php
+++ b/php/signup.php
@@ -6,13 +6,13 @@
$pswd = ($_POST['registerPassword']);
$email = ($_POST['registerMail']);
- $search_user = $database->prepare("SELECT ID FROM user WHERE user='$name '");
+ $search_user = $database->prepare("SELECT ID FROM user WHERE username='$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(username, email, password) VALUES (?,?,?)");
$stmt->bind_param("sss", $name, $email, $pswd);
$stmt->execute();
$stmt->close();
diff --git a/segments/_login.php b/segments/_login.php
index f70b938..a3fb3c6 100644
--- a/segments/_login.php
+++ b/segments/_login.php
@@ -6,14 +6,15 @@ if( (isset($_POST['loginName'])) && isset($_POST['loginPassword'])){
$pswd = ($_POST['loginPassword']);
$pswd = md5($pswd);
- $stmt = $database->prepare("SELECT id FROM user WHERE '$name'=user AND password='$pswd'");
+ $stmt = $database->prepare("SELECT id, username FROM user WHERE '$name'=username AND password='$pswd'");
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows == 1) {
$object = $result->fetch_object();
$_SESSION['user'] = $object->id;
- echo "Einloggen erfolgreich";
+ $_SESSION['username'] = $object->username;
+ echo "Einloggen erfolgreich