internetprogrammierung/php/generateLink.php

30 lines
716 B
PHP
Raw Normal View History

2018-05-26 14:33:15 +02:00
<?php
$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=";
2018-05-26 15:09:18 +02:00
$resultStr = $resultStr . $uniqueID;
2018-05-26 14:33:15 +02:00
2018-05-26 15:09:18 +02:00
insertTan($uniqueID);
2018-05-26 14:33:15 +02:00
$HTMLJSON = array('html' => $resultStr);
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
$stmt = $database->prepare("INSERT INTO tans (tan, used) VALUES (?, ?)");
2018-05-26 15:09:18 +02:00
$false = false;
$stmt->bind_param("si", $tan, $false);
2018-05-26 15:09:18 +02:00
try {
$stmt->execute();
} catch (PDOException $e) {
$e->getMessage();
}
}
2018-05-26 14:33:15 +02:00
?>