app01/ |-api/ | |-create.php | `-read.php |-core/ | `-init.php `-includes/ |-config.php |-database.php `-mariadb.php
$db['host'] = 'localhost'; $db['user'] = 'app01'; $db['pass'] = 'titok'; $db['name'] = 'app01';
header('Access-Control-Allow-Origin: *'); header('Content-Type: application/json'); include_once('../core/init.php');
header('Access-Control-Allow-Origin: *'); header('Content-Type: application/json'); header('Access-Control-Allow-Methods: POST'); include_once('../core/init.php');
<?php header('Access-Control-Allow-Origin: *'); header('Content-Type: application/json'); $method = $_SERVER['REQUEST_METHOD']; $request = $_SERVER['REQUEST_URI']; switch($method) { case 'POST': create_data($request); break; case 'GET': read_data(); break; case 'PUT': update_data($request); break; case 'DELETE': delete_data($request); break; default: handle_error($request); } function create_data($request) {} function read_data() {} function update_data($request) {} function delete_data($request) {} function handle_error($request) {}