Dateien nach "Backend" hochladen

This commit is contained in:
2025-09-03 10:45:17 +02:00
commit 28871900c6
5 changed files with 126 additions and 0 deletions

27
Backend/db.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
function db()
{
static $pdo = null;
if ($pdo)
return $pdo;
$pdo = new PDO("mysql:host=127.0.0.1;dbname=vprmini_simple;charset=utf8mb4", "root", "root", [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
]);
return $pdo;
}
function body()
{
$raw = file_get_contents("php://input");
$j = json_decode($raw, true);
return is_array($j) ? $j : $_POST;
}
function out($ok, $msg, $data = [], $status = 200)
{
http_response_code($status);
header("Content-Type: application/json");
echo json_encode(["ok" => $ok, "msg" => $msg] + $data);
exit;
}