diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c7f7bd3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +dbConnect.php diff --git a/entry.php b/entry.php index 5945bfe..8ee12c5 100644 --- a/entry.php +++ b/entry.php @@ -13,18 +13,7 @@ } function consumeTan($tan) { - //Stelle DB verbindung her - $user = 'root'; - $password = 'root'; - $db = 'friendsbook'; - $host = 'localhost'; - $port = 3306; - - $database = new mysqli($host, $user, $password, $db, $port); - - if ($database->connect_error) { - die('Connect Error (' . $database->connect_errno . ') ' . $database->connect_error); - } + 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 `tan` = '" . $tan . "'"; diff --git a/php/generateLink.php b/php/generateLink.php index 03f9e7e..2bfb25d 100644 --- a/php/generateLink.php +++ b/php/generateLink.php @@ -12,18 +12,7 @@ echo json_encode($HTMLJSON); function insertTan($tan) { - //Stelle DB verbindung her - $user = 'root'; - $password = 'root'; - $db = 'friendsbook'; - $host = 'localhost'; - $port = 3306; - - $database = new mysqli($host, $user, $password, $db, $port); - - if ($database->connect_error) { - die('Connect Error (' . $database->connect_errno . ') ' . $database->connect_error); - } + require('../dbConnect.php'); //Erstellt variable mit dem namen $database $stmt = $database->prepare("INSERT INTO tans (tan, used) VALUES (?, ?)"); diff --git a/~dbConnect.php b/~dbConnect.php new file mode 100644 index 0000000..888225d --- /dev/null +++ b/~dbConnect.php @@ -0,0 +1,18 @@ +connect_error) { + die('Connect Error (' . $database->connect_errno . ') ' . $database->connect_error); +} + +?> \ No newline at end of file