From 2da917312e82a4d660e42394f1fd54c1880685f4 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Sat, 26 May 2018 16:55:33 +0200 Subject: [PATCH] corrected tan usage cant use a tan twice --- entry.php | 51 +++++++++++++++++++++++++++++++++++++++++++- php/addEntry.php | 32 --------------------------- php/generateLink.php | 2 ++ 3 files changed, 52 insertions(+), 33 deletions(-) delete mode 100644 php/addEntry.php diff --git a/entry.php b/entry.php index f77fb29..ae85142 100644 --- a/entry.php +++ b/entry.php @@ -1,4 +1,53 @@ +connect_error) { + die('Connect Error (' . $database->connect_errno . ') ' . $database->connect_error); + } + + //Stelle sicher dass die Tan noch verfügbar ist. + $abfrage = "SELECT `used`, `tan` FROM `tans` WHERE `tan` = '" . $tan . "'"; + $ergebnis = mysqli_query($database, $abfrage); + + $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']; +} + +?> @@ -7,7 +56,7 @@ -
+ Vorname:

Nachname:
diff --git a/php/addEntry.php b/php/addEntry.php deleted file mode 100644 index 0f6b119..0000000 --- a/php/addEntry.php +++ /dev/null @@ -1,32 +0,0 @@ -connect_error) { - die('Connect Error (' . $database->connect_errno . ') ' . $database->connect_error); - } - - $update = $database->query("UPDATE `tans` SET `used`= true WHERE `tan` = '" . $_POST['tan'] . "'"); - - -} - - -?> diff --git a/php/generateLink.php b/php/generateLink.php index e9d0332..03f9e7e 100644 --- a/php/generateLink.php +++ b/php/generateLink.php @@ -2,6 +2,8 @@ $uniqueID = uniqid(); $resultStr = "Neuer eintrag über: http://localhost/github/ipr-projekt/entry.php?tan="; + //Final link + //$resultStr = "Neuer eintrag über: http://localhost/friendsbook/entry.php?tan="; $resultStr = $resultStr . $uniqueID; insertTan($uniqueID);