Example #1
0
<?php

require_once "atc.class.php";
$ATC = new ATC();
$id = isset($_GET['id']) ? (int) $_GET['id'] : null;
if (isset($_POST['firstname_0']) && isset($_GET['id'])) {
    try {
        foreach ($_POST['nok_id'] as $i) {
            if (strlen(trim($_POST['firstname_' . $i])) && strlen(trim($_POST['lastname_' . $i]))) {
                $ATC->set_next_of_kin($i, $_GET['id'], $_POST['firstname_' . $i], $_POST['lastname_' . $i], $_POST['relationship_' . $i], $_POST['email_' . $i], $_POST['mobile_' . $i], $_POST['home_' . $i], $_POST['address1_' . $i], $_POST['address2_' . $i], $_POST['city_' . $i], $_POST['postcode_' . $i]);
            }
        }
    } catch (ATCExceptionInsufficientPermissions $e) {
        header("HTTP/1.0 401 Unauthorised");
        echo 'Caught exception: ', $e->getMessage(), "\n";
        exit;
    } catch (ATCExceptionDBError $e) {
        header("HTTP/1.0 500 Internal Server Error");
        echo 'Caught exception: ', $e->getMessage(), "\n";
        exit;
    } catch (ATCExceptionDBConn $e) {
        header("HTTP/1.0 500 Internal Server Error");
        echo 'Caught exception: ', $e->getMessage(), "\n";
        exit;
    } catch (ATCException $e) {
        header("HTTP/1.0 400 Bad Request");
        echo 'Caught exception: ', $e->getMessage(), "\n";
        exit;
    } catch (Exception $e) {
        header("HTTP/1.0 500 Internal Server Error");
        echo 'Caught exception: ', $e->getMessage(), "\n";