diff --git a/index.php b/index.php
index 92015ab..2595aa1 100644
--- a/index.php
+++ b/index.php
@@ -10,8 +10,10 @@
+
+<<<<<<< HEAD
@@ -42,11 +44,21 @@
+=======
+
+
+
+>>>>>>> 268a8ea290224c0d4de615683d4c8529df7d5252
+
+
+
+
+
diff --git a/js/contentloader.js b/js/contentloader.js
index a6ce3fb..c541829 100644
--- a/js/contentloader.js
+++ b/js/contentloader.js
@@ -1,7 +1,7 @@
window.addEventListener('load', async () => {
console.log("Seite geladen");
- getNewUniqueLink();
- document.getElementById('create').addEventListener('click' , async (event) => createEntry());
+ //getNewUniqueLink();
+ document.getElementById('btnCreateTan').addEventListener('click' , async (event) => getNewUniqueLink());
})
async function getNewUniqueLink() {
@@ -16,18 +16,3 @@ 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
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/_entryForm.php b/segments/_entryForm.php
new file mode 100644
index 0000000..7bd8d50
--- /dev/null
+++ b/segments/_entryForm.php
@@ -0,0 +1,225 @@
+" . $_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'];
+}
+
+?>
+
+
+
diff --git a/segments/_indexTestLoginVals.php b/segments/_indexTestLoginVals.php
new file mode 100644
index 0000000..fb9e96d
--- /dev/null
+++ b/segments/_indexTestLoginVals.php
@@ -0,0 +1,10 @@
+
+ LoginModalData:
+ Welcome
+ Your Password is:
+
+ RegisterModalData:
+ Welcome
+ Your Password is:
+ Your Mail Adress is:
+
diff --git a/sql/entiresTable.sql b/sql/entiresTable.sql
new file mode 100644
index 0000000..1069354
--- /dev/null
+++ b/sql/entiresTable.sql
@@ -0,0 +1,33 @@
+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/userTableSQL b/sql/userTable.sql
similarity index 90%
rename from sql/userTableSQL
rename to sql/userTable.sql
index d232441..b015f21 100644
--- a/sql/userTableSQL
+++ b/sql/userTable.sql
@@ -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`)
-)
+);