php tan corrections

This commit is contained in:
Marcel Schwarz 2018-05-27 19:31:44 +02:00
parent 2da917312e
commit 7108e0019e
2 changed files with 13 additions and 5 deletions

View File

@ -1,9 +1,11 @@
<?php <?php
if(isset($_POST['tan'])){ if(isset($_POST['tan'])){
//echo "Tan ->" . $_POST['tan'] . "<-";
if($_POST['tan'] != ""){
addEntry(); addEntry();
consumeTan($_POST['tan']); consumeTan($_POST['tan']);
}
} }
function addEntry() { function addEntry() {
@ -28,6 +30,11 @@ function consumeTan($tan) {
$abfrage = "SELECT `used`, `tan` FROM `tans` WHERE `tan` = '" . $tan . "'"; $abfrage = "SELECT `used`, `tan` FROM `tans` WHERE `tan` = '" . $tan . "'";
$ergebnis = mysqli_query($database, $abfrage); $ergebnis = mysqli_query($database, $abfrage);
if($ergebnis->num_rows == 0){
echo "Tan nicht vergeben";
return;
}
$resultStr = ""; $resultStr = "";
while ($row = $ergebnis->fetch_assoc()) { while ($row = $ergebnis->fetch_assoc()) {
@ -51,7 +58,7 @@ function consumeTan($tan) {
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<script src="js/newEntry.js"></script> <script src="js/entry.js"></script>
</head> </head>
<body> <body>
@ -65,7 +72,8 @@ function consumeTan($tan) {
<input type="text" name="email"><br> <input type="text" name="email"><br>
Nachricht:<br> Nachricht:<br>
<input type="text" name="eintrag"><br> <input type="text" name="eintrag"><br>
<input type="hidden" name="tan" value="<?php echo $_GET["tan"]?>"><br> Tan:<br>
<input type="text" name="tan"><br>
<input id="absenden" type="submit" value="Abschicken"> <input id="absenden" type="submit" value="Abschicken">
<button type="reset">Loeschen</button> <button type="reset">Loeschen</button>