diff --git a/index.php b/index.php index 92015ab..83b2ead 100644 --- a/index.php +++ b/index.php @@ -44,6 +44,11 @@ +<<<<<<< HEAD +======= + + +>>>>>>> parent of 268a8ea... switched tan from unique id to index diff --git a/js/contentloader.js b/js/contentloader.js index a6ce3fb..3bfacba 100644 --- a/js/contentloader.js +++ b/js/contentloader.js @@ -1,7 +1,13 @@ 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() { @@ -18,7 +24,12 @@ 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', { diff --git a/segments/_entryForm.php b/segments/_entryForm.php new file mode 100644 index 0000000..33436c8 --- /dev/null +++ b/segments/_entryForm.php @@ -0,0 +1,230 @@ +" . $_POST['tan'] . "<-"; + if($_POST['tan'] != ""){ + addEntry(); + consumeTan($_POST['tan']); + } + } + + function addEntry() { + + } + +function consumeTan($tan) { + 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 . "'"; + $ergebnis = mysqli_query($database, $abfrage); + + if($ergebnis->num_rows == 0){ + echo "Tan nicht vergeben"; + return; + } + + $resultStr = ""; + + while ($row = $ergebnis->fetch_assoc()) { + $resultStr = $resultStr . $row["used"] . ' ' . $row["tan"] . '
'; + 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'] . "'"); + + echo "Tan verbraucht " . $_POST['tan']; +} + +?> + + +
+
+ +
+
+ +
+
+ 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/sql/entiresTable.sql b/sql/entiresTable.sql new file mode 100644 index 0000000..aefa654 --- /dev/null +++ b/sql/entiresTable.sql @@ -0,0 +1,33 @@ +CREATE TABLE `kd42696_ipr-projekt`.`entries` ( + `entryID` 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 (`entryID`), + 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;