2018-05-26 14:33:15 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
$uniqueID = uniqid();
|
|
|
|
|
2018-05-26 15:09:18 +02:00
|
|
|
insertTan($uniqueID);
|
2018-05-26 14:33:15 +02:00
|
|
|
|
2018-06-11 17:56:22 +02:00
|
|
|
$resultStr = getTanID($uniqueID);
|
|
|
|
|
2018-06-17 23:05:13 +02:00
|
|
|
$HTMLJSON = array('html' => $resultStr , 'userid' => $_POST['phpSession']);
|
2018-05-26 14:33:15 +02:00
|
|
|
echo json_encode($HTMLJSON);
|
|
|
|
|
2018-05-26 15:09:18 +02:00
|
|
|
function insertTan($tan) {
|
2018-06-01 20:43:25 +02:00
|
|
|
require('../dbConnect.php'); //Erstellt variable mit dem namen $database
|
2018-05-26 15:09:18 +02:00
|
|
|
|
2018-06-11 17:56:22 +02:00
|
|
|
$stmt = $database->prepare("INSERT INTO tans (tan, userID, used) VALUES (?, ?, ?)");
|
2018-05-26 15:09:18 +02:00
|
|
|
|
2018-06-11 17:56:22 +02:00
|
|
|
$used = false;
|
2018-06-17 23:05:13 +02:00
|
|
|
$userid = $_POST['phpSession'];
|
|
|
|
//$userid = $_SESSION['user'];
|
|
|
|
//$userid = $_POST['userid'];
|
2018-06-11 17:56:22 +02:00
|
|
|
$stmt->bind_param("ssi", $tan, $userid, $used);
|
2018-05-26 15:09:18 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
$stmt->execute();
|
2018-06-11 17:56:22 +02:00
|
|
|
$database->close();
|
2018-05-26 15:09:18 +02:00
|
|
|
} catch (PDOException $e) {
|
|
|
|
$e->getMessage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-11 17:56:22 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-05-26 14:33:15 +02:00
|
|
|
?>
|