Exemplo n.º 1
0
 * Sanitize vars
*/
if (!isset($_GET["url"])) {
    $url = "login";
} else {
    $url = filter_var($_GET['url'], FILTER_SANITIZE_STRING);
}
/*
 * Check URL to send request to the right controller
*/
switch ($url) {
    case "login":
        include_once "controllers/UserController.php";
        $user = new UserController();
        $user->login();
        $user->showLogin();
        break;
    case "logout":
        include_once "controllers/UserController.php";
        $user = new UserController();
        $user->logout();
        break;
    case "register":
        include_once "controllers/UserController.php";
        $user = new UserController();
        $user->register();
        break;
    case "user":
        include_once "controllers/UserController.php";
        $user = new UserController();
        if ($_GET["action"] == "update") {
Exemplo n.º 2
0
<?php

$routes->get('/', function () {
    DrinkController::front();
});
$routes->get('/register', function () {
    UserController::registration();
});
$routes->post('/register', function () {
    UserController::registerUser();
});
$routes->get('/login', function () {
    UserController::showLogin();
});
$routes->post('/login', function () {
    UserController::login();
});
$routes->get('/logout', function () {
    UserController::logout();
});
$routes->get('/users', function () {
    UserController::showUsers();
});
$routes->get('/user/:id', function ($id) {
    UserController::showUser($id);
});
$routes->post('/users/:id/destroy', function ($id) {
    UserController::destroyUser($id);
});
$routes->get('/users/:id/edit', function ($id) {
    UserController::editUser($id);