From dc524ac00c89ba7353d0a5a8786edb5e63795d21 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Mon, 11 Jun 2018 17:56:22 +0200 Subject: [PATCH] solved merge problems This reverts commit 268a8ea290224c0d4de615683d4c8529df7d5252. --- index.php | 41 ++---- js/contentloader.js | 26 ---- js/entry.js | 0 php/generateLink.php | 23 +++- readme.md | 3 - segments/_entry.html | 194 ---------------------------- segments/_entryForm.php | 35 +++-- segments/_header.html | 1 - segments/_indexTestLoginVals.php | 10 ++ sql/entiresTable.sql | 4 +- sql/{userTableSQL => userTable.sql} | 4 +- 11 files changed, 58 insertions(+), 283 deletions(-) delete mode 100644 js/entry.js delete mode 100644 segments/_entry.html create mode 100644 segments/_indexTestLoginVals.php rename sql/{userTableSQL => userTable.sql} (90%) diff --git a/index.php b/index.php index 83b2ead..ea405c7 100644 --- a/index.php +++ b/index.php @@ -8,50 +8,27 @@ + + + + - - - - - -
- +
-
- LoginModalData: - Welcome
- Your Password is:
-
- RegisterModalData: - Welcome
- Your Password is:
- Your Mail Adress is:
-
- - - -
-
-
-
-
-
- - - -<<<<<<< HEAD -======= + + + ->>>>>>> parent of 268a8ea... switched tan from unique id to index + diff --git a/js/contentloader.js b/js/contentloader.js index 3bfacba..c541829 100644 --- a/js/contentloader.js +++ b/js/contentloader.js @@ -1,13 +1,7 @@ window.addEventListener('load', async () => { console.log("Seite geladen"); -<<<<<<< HEAD - getNewUniqueLink(); - document.getElementById('create').addEventListener('click' , async (event) => createEntry()); -======= //getNewUniqueLink(); document.getElementById('btnCreateTan').addEventListener('click' , async (event) => getNewUniqueLink()); - document.getElementById('btnAbsenden').addEventListener('click' , async (event) => createEntry()); ->>>>>>> parent of 268a8ea... switched tan from unique id to index }) async function getNewUniqueLink() { @@ -22,23 +16,3 @@ async function getNewUniqueLink() { } } -async function createEntry() { - event.preventDefault() -<<<<<<< HEAD - const formData = new formData(document.getElementById('create-form')); -======= - console.log("Absenden gedrueckt!!!!"); - const formData = new formData(document.getElementById('entry-form')); ->>>>>>> parent of 268a8ea... switched tan from unique id to index - - try { - const response = await fetch('php/login.php', { - method: 'post', - body: formData - }); - const jsonData = await response.json(); - - } catch (e) { - console.log("Fehler"); - } -} diff --git a/js/entry.js b/js/entry.js deleted file mode 100644 index e69de29..0000000 diff --git a/php/generateLink.php b/php/generateLink.php index 2bfb25d..a3d60a1 100644 --- a/php/generateLink.php +++ b/php/generateLink.php @@ -8,22 +8,39 @@ insertTan($uniqueID); + $resultStr = getTanID($uniqueID); + $HTMLJSON = array('html' => $resultStr); echo json_encode($HTMLJSON); function insertTan($tan) { require('../dbConnect.php'); //Erstellt variable mit dem namen $database - $stmt = $database->prepare("INSERT INTO tans (tan, used) VALUES (?, ?)"); + $stmt = $database->prepare("INSERT INTO tans (tan, userID, used) VALUES (?, ?, ?)"); - $false = false; - $stmt->bind_param("si", $tan, $false); + $used = false; + $userid = 1; + $stmt->bind_param("ssi", $tan, $userid, $used); try { $stmt->execute(); + $database->close(); } catch (PDOException $e) { $e->getMessage(); } } + function getTanID($tan){ + require('../dbConnect.php'); //Erstellt variable mit dem namen $database + $abfrage = "SELECT `id` FROM `tans` WHERE `tan` = '" . $tan . "'"; + + $ergebnis = mysqli_query($database, $abfrage); + + $row = $ergebnis->fetch_object(); + $resultStr = $row->id; + + + return $resultStr; + } + ?> diff --git a/readme.md b/readme.md index f42fbb4..23068f1 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,3 @@ Link to Project: https://icaotix.github.io/ipr-projekt/ - -Info: index.php -form with php_post in line 61 and 97, feel free to change the destination path. diff --git a/segments/_entry.html b/segments/_entry.html deleted file mode 100644 index be5da79..0000000 --- a/segments/_entry.html +++ /dev/null @@ -1,194 +0,0 @@ - - - - -
-
-
-
- -
- -
- -
-
- Vorname* -
- -
- -
-
- Nachname* -
- -
- -
-
- Geburtstag -
- -
- -
-
- Wohnort -
- -
- -
-
- Straße -
- -
- -
-
- Woher kennen wir uns?* -
- -
- -
-
- Festnetz -
- -
- -
-
- Handynummer -
- -
- -
-
- E-Mail* -
- -
- -
-
- Hobbys -
- -
- -
-
- Berufswunsch -
- -
- -
-
- Das könnte ich jeden Tag essen -
- -
- -
-
- Was ich auf eine Insel mitnehmen würde -
- -
- -
-
- Lieblingsfilm -
- -
- -
-
- Lieblingssport -
- -
- -
-
- Coolster Film oder Spielecharaker -
- -
- -
-
- Mein Lieblingstier -
- -
- -
-
- Lieblingsmusik(Genre, Interpret, Titel) -
- -
- -
-
- Geilstes Game -
- -
- -
-
- Lieblings alkoholisches Getränk -
- -
- -
-
- Meine heftigste Suffstory -
- -
- -
-
- Letzer Absturz -
- -
- -
-
- Lieblings Trinkspiel -
- -
- -
-
- friendsTAN* -
- -
- - - -
-
- -
-
-
-
diff --git a/segments/_entryForm.php b/segments/_entryForm.php index 33436c8..7bd8d50 100644 --- a/segments/_entryForm.php +++ b/segments/_entryForm.php @@ -1,10 +1,10 @@ " . $_POST['tan'] . "<-"; - if($_POST['tan'] != ""){ + if($_POST['tanID'] != ""){ addEntry(); - consumeTan($_POST['tan']); + consumeTan($_POST['tanID']); } } @@ -12,11 +12,11 @@ } -function consumeTan($tan) { - require('../dbConnect.php'); //Erstellt variable mit dem namen $database +function consumeTan($tanID) { + require('dbConnect.php'); //Erstellt variable mit dem namen $database //Stelle sicher dass die Tan noch verfügbar ist. - $abfrage = "SELECT `used`, `tan` FROM `tans` WHERE `tan` = '" . $tan . "'"; + $abfrage = "SELECT `used`, `tan` FROM `tans` WHERE `id` = '" . $tanID . "'"; $ergebnis = mysqli_query($database, $abfrage); if($ergebnis->num_rows == 0){ @@ -26,21 +26,16 @@ function consumeTan($tan) { $resultStr = ""; - while ($row = $ergebnis->fetch_assoc()) { - $resultStr = $resultStr . $row["used"] . ' ' . $row["tan"] . '
'; - if($row["used"] == 1){ - echo "Tan schon verbraucht"; - return; - } - + $row = $ergebnis->fetch_object(); + if($row->used == 1){ + echo "Tan schon verbraucht"; + return; } - //echo $resultStr; - //Setzte Tan auf verbraucht - $update = $database->query("UPDATE `tans` SET `used`= true WHERE `tan` = '" . $_POST['tan'] . "'"); + $update = $database->query("UPDATE `tans` SET `used`= true WHERE `id` = '" . $_POST['tanID'] . "'"); - echo "Tan verbraucht " . $_POST['tan']; + echo "Tan verbraucht " . $_POST['tanID']; } ?> @@ -50,7 +45,7 @@ function consumeTan($tan) {
-
+
@@ -217,14 +212,14 @@ function consumeTan($tan) {
Eintrags-TAN*
- +
- +
diff --git a/segments/_header.html b/segments/_header.html index fe3248f..f10e2d1 100644 --- a/segments/_header.html +++ b/segments/_header.html @@ -1,4 +1,3 @@ -