-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproducts.php
More file actions
36 lines (32 loc) · 822 Bytes
/
products.php
File metadata and controls
36 lines (32 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
// Created by Aaron Knoll
// Licensed under the GNU GPLv3
// (a copy of which is contained along with this application)
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE");
require_once 'create.php';
require_once 'read.php';
require_once 'update.php';
require_once 'delete.php';
// For debugging
// ini_set('display_errors', 'On');
// error_reporting(E_ALL);
// Perform appropriate CRUD operation based on HTTP request method
switch ($_SERVER['REQUEST_METHOD']) {
case 'POST':
createEntries();
break;
case 'GET':
readEntries();
break;
case 'PUT':
updateEntries();
break;
case 'DELETE':
deleteEntries();
break;
default:
http_response_code(400);
echo 'Invalid request method.';
}