diff --git a/index.php b/index.php index 2595aa1..92015ab 100644 --- a/index.php +++ b/index.php @@ -10,10 +10,8 @@ - -<<<<<<< HEAD @@ -44,21 +42,11 @@

-======= -
- -
->>>>>>> 268a8ea290224c0d4de615683d4c8529df7d5252 - - - - - diff --git a/js/contentloader.js b/js/contentloader.js index c541829..a6ce3fb 100644 --- a/js/contentloader.js +++ b/js/contentloader.js @@ -1,7 +1,7 @@ window.addEventListener('load', async () => { console.log("Seite geladen"); - //getNewUniqueLink(); - document.getElementById('btnCreateTan').addEventListener('click' , async (event) => getNewUniqueLink()); + getNewUniqueLink(); + document.getElementById('create').addEventListener('click' , async (event) => createEntry()); }) async function getNewUniqueLink() { @@ -16,3 +16,18 @@ async function getNewUniqueLink() { } } +async function createEntry() { + event.preventDefault() + const formData = new formData(document.getElementById('create-form')); + + 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 new file mode 100644 index 0000000..e69de29 diff --git a/php/generateLink.php b/php/generateLink.php index a3d60a1..2bfb25d 100644 --- a/php/generateLink.php +++ b/php/generateLink.php @@ -8,39 +8,22 @@ 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, userID, used) VALUES (?, ?, ?)"); + $stmt = $database->prepare("INSERT INTO tans (tan, used) VALUES (?, ?)"); - $used = false; - $userid = 1; - $stmt->bind_param("ssi", $tan, $userid, $used); + $false = false; + $stmt->bind_param("si", $tan, $false); 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 23068f1..f42fbb4 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,6 @@ 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/_entryForm.php b/segments/_entryForm.php deleted file mode 100644 index 7bd8d50..0000000 --- a/segments/_entryForm.php +++ /dev/null @@ -1,225 +0,0 @@ -" . $_POST['tan'] . "<-"; - if($_POST['tanID'] != ""){ - addEntry(); - consumeTan($_POST['tanID']); - } - } - - function addEntry() { - - } - -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 `id` = '" . $tanID . "'"; - $ergebnis = mysqli_query($database, $abfrage); - - if($ergebnis->num_rows == 0){ - echo "Tan nicht vergeben"; - return; - } - - $resultStr = ""; - - $row = $ergebnis->fetch_object(); - if($row->used == 1){ - echo "Tan schon verbraucht"; - return; - } - - //Setzte Tan auf verbraucht - $update = $database->query("UPDATE `tans` SET `used`= true WHERE `id` = '" . $_POST['tanID'] . "'"); - - echo "Tan verbraucht " . $_POST['tanID']; -} - -?> - - -
-
- -
-
- -
-
- Vorname* -
- -
- -
-
- Nachname* -
- -
- -
-
- Geburtstag -
- -
- -
-
- Wohnort -
- -
- -
-
- Straße -
- -
- -
-
- Woher kennen wir uns?* -
- -
- -
-
- Festnetz -
- -
- -
-
- Handynummer -
- -
- -
-
- E-Mail* -
- -
- -
-
- Hobbies -
- -
- -
-
- 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 -
- -
- -
-
- Eintrags-TAN* -
- -
- - - - -
-
-
diff --git a/segments/_indexTestLoginVals.php b/segments/_indexTestLoginVals.php deleted file mode 100644 index fb9e96d..0000000 --- a/segments/_indexTestLoginVals.php +++ /dev/null @@ -1,10 +0,0 @@ -
- LoginModalData: - Welcome
- Your Password is:
-
- RegisterModalData: - Welcome
- Your Password is:
- Your Mail Adress is:
-
diff --git a/sql/entiresTable.sql b/sql/entiresTable.sql deleted file mode 100644 index 1069354..0000000 --- a/sql/entiresTable.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE `kd42696_ipr-projekt`.`entries` ( - `id` INT NOT NULL AUTO_INCREMENT , - `userID` INT NOT NULL , - `tanID` INT NOT NULL , - `vorname` LONGTEXT NOT NULL , - `nachname` LONGTEXT NOT NULL , - `geburtstag` LONGTEXT NOT NULL , - `wohnort` LONGTEXT NOT NULL , - `strasse` LONGTEXT NOT NULL , - `kennenUns` LONGTEXT NOT NULL , - `festnetz` LONGTEXT NOT NULL , - `handynummer` LONGTEXT NOT NULL , - `email` LONGTEXT NOT NULL , - `hobbies` LONGTEXT NOT NULL , - `berufswunsch` LONGTEXT NOT NULL , - `essen` LONGTEXT NOT NULL , - `insel` LONGTEXT NOT NULL , - `film` LONGTEXT NOT NULL , - `sport` LONGTEXT NOT NULL , - `charakter` LONGTEXT NOT NULL , - `tier` LONGTEXT NOT NULL , - `musik` LONGTEXT NOT NULL , - `game` LONGTEXT NOT NULL , - `alk` LONGTEXT NOT NULL , - `story` LONGTEXT NOT NULL , - `absturz` LONGTEXT NOT NULL , - `trinkspiel` LONGTEXT NOT NULL , - PRIMARY KEY (`id`), - UNIQUE (`userID`), - 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 (`tanID`) REFERENCES `tans`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/sql/userTable.sql b/sql/userTableSQL similarity index 90% rename from sql/userTable.sql rename to sql/userTableSQL index b015f21..d232441 100644 --- a/sql/userTable.sql +++ b/sql/userTableSQL @@ -3,6 +3,6 @@ CREATE TABLE `user` ( `user` VARCHAR(50) NOT NULL DEFAULT '0', `email` VARCHAR(100) NOT NULL DEFAULT '0', `password` VARCHAR(100) NOT NULL DEFAULT '0', - PRIMARY KEY (`ID`), + PRIMARY KEY (`ID`) UNIQUE INDEX `user` (`user`) -); +)