1
0

Erster Commit

This commit is contained in:
Anna Christina Naß
2025-07-07 16:25:22 +02:00
parent 3b9e7bb194
commit ce5baaac35
23 changed files with 671 additions and 2 deletions

33
test.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
require_once 'Twig/autoload.php';
require_once 'config.php';
require_once 'functions.php';
use Twig\Environment;
use Twig\Loader\FilesystemLoader;
$loader = new FilesystemLoader(__DIR__ . '/templates');
$twig = new Environment($loader);
// --------------
if (!isset($_GET['id']))
die(twig_error($twig, 400, "Keine ID angegeben."));
$id = (int)$_GET['id'];
$dbconn = pg_connect($dbconnstring)
or die(twig_error($twig, 500, 'Datenbankfehler: ' . pg_last_error()));
$query = "SELECT data FROM tests WHERE id=" . $id;
$result = pg_query($dbconn, $query)
or die(twig_error($twig, 'Datenbankfehler: ' . pg_last_error()));
$json = pg_fetch_result($result, 'data')
or die(twig_error($twig, 404, 'Test nicht gefunden.'));
pg_close($dbconn);
echo $twig->render('test.html.twig', [ 'test' => $json ]);
?>