<?php require_once realpath($_SERVER['DOCUMENT_ROOT']) . '/includes/init_member.inc.php'; require_once realpath($_SERVER['DOCUMENT_ROOT']) . '/includes/init_trigger.inc.php'; if (isset($_POST['fullname']) && isset($_POST['dob'])) { create_person($_POST['fullname'], $_POST['dob']); }
$header = array('Authorization' => $_SESSION['token'], 'Content-Type' => 'application/json', 'Accept' => 'application/json'); $response = $client->fetch($baseApiUrl . '/api/v1/people/' . $details['id'], json_encode($params), 'PUT', $header, 0); header('Location: index.php'); } function update_event($details) { global $client, $baseApiUrl, $baseSiteSlug; $params = array('event' => array('name' => $details['name'], 'status' => $details['status'], 'start_time' => $details['start_time'], 'end_time' => $details['end_time'])); $header = array('Authorization' => $_SESSION['token'], 'Content-Type' => 'application/json', 'Accept' => 'application/json'); $response = $client->fetch($baseApiUrl . '/api/v1/sites/' . $baseSiteSlug . '/pages/events/' . $details['id'], json_encode($params), 'PUT', $header, 0); header('Location: index.php'); } function delete_person($id) { global $client, $baseApiUrl; $response = $client->fetch($baseApiUrl . '/api/v1/people/' . $id, array(), 'DELETE'); header('Location: index.php'); } if (isset($_GET['create']) && $_GET['create'] == 'create') { create_person($_GET); } elseif (isset($_GET['update']) && $_GET['update'] == 'update') { update_person($_GET); } elseif (isset($_GET['delete'])) { delete_person($_GET['delete']); } elseif (isset($_GET['updateEvent'])) { if (isset($_GET['id'])) { update_event($_GET); } else { create_event($_GET); } }
<?php // configuration require "../includes/directory_functions.php"; if ($_SERVER["REQUEST_METHOD"] == "POST") { // create the person if (create_person($_POST['name'], $_POST['house'], $_POST['age']) === false) { apologize("There was a problem with creating the entry. Please try again"); } redirect("/"); } else { // render add person form render("people/add.php"); }