Ejemplo n.º 1
0
<?php

include '../core/config.php';
include '../core/validations.php';
//Process Registration
if (count($_POST)) {
    /*
     * Covert POST into a Collection object
     * for better values handling
     */
    $input = new \ptejada\uFlex\Collection($_POST);
    /*
     * If the form fields names match your DB columns then you can reduce the collection
     * to only those expected fields using the filter() function
     */
    $input->filter('Username', 'first_name', 'last_name', 'Email', 'Password', 'Password2', 'website', 'GroupID');
    /*
     * Register the user
     * The register method takes either an array or a Collection
     */
    $user->register($input);
    echo json_encode(array('error' => $user->log->getErrors(), 'confirm' => 'User Registered Successfully. You may login now!', 'form' => $user->log->getFormErrors()));
}
Ejemplo n.º 2
0
<?php

include '../core/config.php';
include '../core/validations.php';
//Process Update
if (count($_POST)) {
    /*
     * Covert POST into a Collection object
     * for better value handling
     */
    $input = new \ptejada\uFlex\Collection($_POST);
    /*
     * Updates queue
     */
    foreach ($input->toArray() as $name => $val) {
        if (is_null($user->getProperty($name))) {
            /*
             * If the field is not part of the user properties
             * then reject the update
             */
            unset($input->{$name});
        } else {
            /*
             * If the value is the same as the tha value stored
             * on the user properties then reject the update
             */
            if ($user->{$name} == $val) {
                unset($input->{$name});
            }
        }
    }