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
This commit is contained in:
24
api/calls/get_item.php
Normal file
24
api/calls/get_item.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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']);
|
||||
}
|
||||
Reference in New Issue
Block a user