Files
Travel-tracker/api/calls/get_item.php
Bram Prieshof e88269224c Added backend and refactored frond-end to support it.
* Removed unecesery home page
* Added PHP Api that provides auth and replaces the json-server for data storage
* Added support for alternate geocode-api
* Added registration  page
2025-05-27 00:42:00 +02:00

25 lines
556 B
PHP

<?php
session_start();
if (!isset($_SESSION['name'])) {
http_response_code(401);
echo json_encode(['message' => 'Unauthorized']);
die;
}
require_once 'config/db.php';
$id = isset($_GET['id']) ? $_GET['id'] : die('Item ID not provided');
$query = "SELECT * FROM items WHERE id = :id";
$stmt = $pdo->prepare($query);
$stmt->bindParam(':id', $id);
$stmt->execute();
$item = $stmt->fetch(PDO::FETCH_ASSOC);
if ($item) {
echo json_encode($item);
} else {
http_response_code(404);
echo json_encode(['message' => 'Item not found']);
}