Ejemplo n.º 1
0
    $newAddressData[0] = $_SESSION['currentUserID'];
    $newAddressData[1] = filter_input(INPUT_POST, 'selected_address_group');
    $newAddressData[2] = filter_input(INPUT_POST, 'fullname');
    $newAddressData[3] = filter_input(INPUT_POST, 'email');
    $newAddressData[4] = filter_input(INPUT_POST, 'address');
    $newAddressData[5] = formatPhone(stripPhone(filter_input(INPUT_POST, 'phone')));
    $newAddressData[6] = filter_input(INPUT_POST, 'website');
    $newAddressData[7] = filter_input(INPUT_POST, 'birthday');
    $errors = validation($newAddressData);
    if (count($errors) == 0) {
        $newAddressData[8] = uploadImage();
        if (empty($newAddressData[8])) {
            $errors[] = 'Image could not be uploaded';
            $results = 'Empty Image';
        }
        if (createContact($newAddressData)) {
            $results = 'New item added to address book';
        } else {
            $results = 'Item was not Added';
        }
    } else {
        $results = 'Errors found';
    }
}
?>

        <?php 
if (isset($errors) && count($errors) > 0) {
    ?>
            <ul>
                <?php 
    }
    if (!isValidBirthday($birthday)) {
        $errors[] = 'birthday is not Valid';
    }
    if (!isValidAddress($address)) {
        $errors[] = 'address is not Valid';
    }
    if (!isValidPhone($phone)) {
        $errors[] = 'Phone Number is not Valid';
    }
    if (!isValidWebsite($website)) {
        $errors[] = 'website is not Valid';
    }
    // As long as no errors are trigger it will allow the the Funtion to Add the Information to the Database
    if (count($errors) == 0) {
        if (createContact($addressgroupid, $fullname, $email, $birthday, $address, $phone, $website)) {
            $results = 'Contact Added';
        } else {
            $results = 'Contact was not Added';
        }
    }
}
?>
        
        <!-- Provides the Results of Contact Creation & the Login Form 
        
             The Add Contact form is also included Below
        -->
        
        <?php 
include '../../Includes/errors.html.php';
Ejemplo n.º 3
0
            case BARN:
                $inBarn = $typeCheck->obj;
                if ($inBarn != null) {
                    $barnId = createBarn($inBarn->id, $inBarn->name);
                    if ($barnId > 0) {
                        $barn = R::load(BARN, $barnId);
                        echo json_encode($barn->export());
                    }
                }
                break;
                /* ADD A CONTACT TO AN EVENT */
            /* ADD A CONTACT TO AN EVENT */
            case CONTACT:
                $inContact = $typeCheck->obj;
                if ($inContact != null) {
                    $contactId = createContact($inContact->id, $inContact->firstname, $inContact->lastname, $inContact->email, $inContact->phone, $inContact->occupationId);
                    if ($contactId > 0) {
                        $contact = R::load(CONTACT, $contactId);
                        echo json_encode($contact->export());
                    }
                }
                break;
        }
    }
});
/* SPECIFIC EVENT */
$app->post('/event/:eventId', function ($eventId) {
    $body = http_get_request_body();
    if ($body != null) {
        $typeCheck = json_decode($body);
        switch ($typeCheck->type) {
Ejemplo n.º 4
0
 */
$app->get('/contacts/:id', function ($id) use($app) {
    $body = $app->request->getBody();
    $body = json_decode($body, true);
    $response = getContact($body, $id);
    header('Content-Type: application/json');
    $app->response->setStatus(200);
    echo json_encode($response);
});
/**
 *  Post: create new contact and post contact info
 */
$app->post('/contacts', function () use($app) {
    $body = $app->request->getBody();
    $body = json_decode($body, true);
    $response = createContact($body);
    header('Content-Type: application/json');
    $app->response->setStatus(200);
    echo json_encode($response);
});
/**
 *  Put: update contact info
 */
$app->put("/contacts/:id", function ($id) use($app) {
    $body = $app->request->getBody();
    $body = json_decode($body, true);
    $response = updateContactInfo($body, $id);
    header('Content-Type: application/json');
    $app->response->setStatus(200);
    echo json_encode($response);
});