new Notification('error', 'Het ingegeven paswoord is niet geldig. Vul een geldig paswoord in.');
        header('location: registratie-form.php');
    } else {
        $connection = new PDO('mysql:host=localhost;dbname=opdracht-crud-cms', 'root', 'root');
        $db = new Database($connection);
        $queryString = 'SELECT * 
												FROM users
												WHERE email = :email';
        $parameters = array(':email' => $email);
        $userData = $db->query($queryString, $parameters);
        /* Als er iets in de array $userData[ 'data' ] zit betekent dit dat het email adres al in de databank zit */
        if (isset($userData['data'][0])) {
            new Notification('error', 'Het ingegeven e-mail adres (' . $email . ') is reeds in gebruik.');
            header('location: registratie-form.php');
        } else {
            User::createNewUser($connection, $email, $password);
            new Notification('succes', 'Uw registratie is gelukt. Welkom.');
            /* SESSION unsetten zodat er geen ingegeven paswoord en email komt wanneer je terug op registratie pagina komt */
            unset($_SESSION['registratie']);
            header('location: dashboard.php');
        }
    }
} else {
    header('location: login-form.php');
}
function generatePassword($lengte, $hoofdletters = true, $kleineLetters = true, $cijfers = false, $specialeTekens = false)
{
    $paswoord = "";
    $paswoordKarakters = array();
    $karaktersHoofdletters = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
    $karaktersKleineLetters = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
Example #2
0
        $app->halt(401);
    }
}
$app->get('/', function () {
    global $app;
    $app->halt(401);
});
$app->get('/user/', function () use($user) {
    echo json_encode($user->getAllUsers());
});
$app->get('/user/:id/', function ($id) use($user) {
    echo json_encode($user->getUserById($id));
});
$app->post('/user/', function () use($user, $app) {
    $new_user = json_decode($app->request->getBody(), true);
    $success = $user->createNewUser($new_user);
    echo $success;
});
$app->delete('/user/:id/', function ($id) use($user) {
    echo $user->deleteUser($id);
});
$app->put('/user/:id/', function ($id) use($user, $app) {
    $details = json_decode($app->request->getBody());
    echo $user->updateUser($id, $details);
});
$app->post('/login/', function () use($app) {
    $login = new Login();
    $email = $app->request->post('email');
    $password = $app->request->post('password');
    if ($login->match($email, $password)) {
        echo json_encode(array("success" => "true"));
Example #3
0
<?php

require "includes.php";
if (isset($_POST['email'])) {
    $user = User::createNewUser($_POST['email'], $_POST['passwd'], $_POST['display_name']);
    if ($user !== false) {
        $_SESSION['user'] =& $user;
        echo "Your account has been created and you are signed in.  Click <a href='index.php'>Here to continue</a>";
    } else {
        echo "The email is already in use.";
    }
} else {
    ?>

		<?php 
    echo $header;
    ?>
<div class="container">
<div class="row">
<h1>Hero Registration</h1>

<form method="post" onsubmit="return checkSignupForm(this);">
E-Mail*:<br/>
<input type="text" name="email"/><br/>
Password:<br/>
<input type="password" name="passwd"/><br/>
Confirm Password:<br/>
<input type="password" name="cpasswd"/><br/>
Display Name: (what is shown on the scoreboard)<br/>
<input type="text" name="display_name"/>
<br/>
Example #4
0
<?php

require __DIR__ . "/../bourbon/user.php";
$status_message = '';
// Status messages, default to nothing
$form_error = null;
$u = new User();
$u->auth(null);
// Handle Post Request
if (WEB::_req('POST')) {
    $user_name = WEB::_post('user_name');
    $user_email = WEB::_post('user_email');
    $user_password = WEB::_post('user_password');
    $user_notify = WEB::_post('user_notify');
    $form_error = $u->validateParams(array($user_name, $user_email, $user_password));
    if (is_null($form_error) && !is_null($user_name) && !is_null($user_email) && !is_null($user_password) && $u->createNewUser($user_email, $user_password, $user_name, $user_notify)) {
        $status_message = WEB::_success('User Successfully Created!');
    } else {
        $status_message = WEB::_error('There is an error when you were creating the User. Please review the form below!', $form_error);
    }
}
?>


<?php 
include __DIR__ . "/../bourbon/template/header.php";
?>

	
<div class="page-header">
	<h1>Create a New Label<small></small></h1>
 * @code: Status code for results follow html statuses and return '200' when everythin is hunky-dory
 **/
$code = '200';
//occasionaly we need to get metaData before we've loaded a user.
if (isset($_POST['form']) && $_POST['form'] == 'create_user') {
    $result = array('users' => array(), 'addresses' => array(), 'phones' => array(), 'emails' => array());
    require_once APPLICATION_PATH . MODEL_DIR . '/User.php';
    require_once APPLICATION_PATH . MODEL_DIR . '/Email.php';
    require_once APPLICATION_PATH . MODEL_DIR . '/Phone.php';
    require_once APPLICATION_PATH . MODEL_DIR . '/Address.php';
    //$core_data	= new Data();
    $user = new User();
    $address = new Address();
    $email = new Email();
    $phone = new Phone();
    $user_id = $user->createNewUser($_POST['user']);
    if ($user_id > 0) {
        $result['users'][] = $user_id;
        foreach ($_POST['address'] as $addy_type_name => $addyData) {
            $address_id = $address->createNewAddress($addyData, $user_id);
            $result['addresses'][] = $address_id;
        }
        foreach ($_POST['phone'] as $phone_type_name => $phoneData) {
            $phone_id = $phone->createNewPhone($phoneData, $user_id);
            $result['phones'][] = $phone_id;
        }
        foreach ($_POST['email'] as $email_type_name => $emailData) {
            $email_id = $email->createNewEmail($emailData, $user_id);
            $result['emails'][] = $email_id;
        }
    }
Example #6
0
require_once dirname(__FILE__) . '/../core/Friends.class.php';
$friend = new Friends();
// Get the class that controls all the login functions
require_once dirname(__FILE__) . '/../core/Login.class.php';
$login = new Login();
/**
 * User
 */
$app->get('/user/:id', function ($id) use($user) {
    echo json_encode($user->getUserById($id));
});
$app->post('/user', function () use($user, $app, $login) {
    $user_details = $app->request->getBody();
    $data = json_decode($user_details, true);
    // And finally send all the array to the createNewuser method
    $error = $user->createNewUser($data, $login);
    echo json_encode($error);
});
$app->delete('/user/:id', function ($id) use($user) {
    echo $user->deleteUser($id);
});
$app->put('/user', function () use($user, $app, $login) {
    $details = json_decode($app->request->getBody(), true);
    echo json_encode($user->updateUserGeneral($_SESSION['auth']['user_id'], $details, $login));
});
/**
 * User profile
 */
$app->post('/uploadPhoto', function () use($user, $app, $login) {
    echo json_encode($user->uploadPhoto($_SESSION['auth']['user_id'], $_FILES['photo'], $login));
});