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:
22
api/calls/delete_item.php
Normal file
22
api/calls/delete_item.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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 = "DELETE FROM items WHERE id = :id";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->bindParam(':id', $id);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['message' => 'Item deleted successfully']);
|
||||
} else {
|
||||
http_response_code(400);
|
||||
echo json_encode(['message' => 'Failed to delete item']);
|
||||
}
|
||||
Reference in New Issue
Block a user