extracted db connection
This commit is contained in:
parent
8a1b946f8e
commit
669b5b3859
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
dbConnect.php
|
13
entry.php
13
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 . "'";
|
||||
|
@ -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 (?, ?)");
|
||||
|
||||
|
18
~dbConnect.php
Normal file
18
~dbConnect.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
//Create DB connection.
|
||||
//This creates a usable "database" - Variable as mysqli Objekt
|
||||
//simply remove the "~" in front of the filename
|
||||
$user = 'user';
|
||||
$password = 'password';
|
||||
$db = 'database name';
|
||||
$host = 'ip or domain';
|
||||
$port = 3306;
|
||||
|
||||
$database = new mysqli($host, $user, $password, $db, $port);
|
||||
|
||||
if ($database->connect_error) {
|
||||
die('Connect Error (' . $database->connect_errno . ') ' . $database->connect_error);
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user