Basic login with router It's not finished yet, but I want to know if the structure and the classes are ok and what can I change. Feel free to say anything.

To be more specific, I want to know what you think about the login function in the Login_Controller class:

public function login() {
            if (!empty($_POST['username']) &amp;&amp; !empty($_POST['password'])) {
                    $user = new Users_Model;

                    $username = $_POST['username'];
                    $password = $_POST['password'];

                    if ($iduser = $user-&gt;is_registered($username, $password)) {
                            $_SESSION['user'] = $username;
                            $_SESSION['iduser'] = $iduser;
                            if ($_POST['keep']) {
                                    $user-&gt;save_cookie($username);
                            }
                            header('Location: ' . SITE_ROOT);
                            exit();
                    } else {
                            $error = 'El usuario o el password no son correctos.';
                            $this-&gt;main($error);
                    }
            } else {
                    $error = 'No ingreso el usuario o el password.';
                    $this-&gt;main($error);
            }
    }


And the router as well:

class Router {
    static function init($request)
    {
            $parsed = explode('/', $request);
            if ($parsed[0] == 'admin') {
                    $page = array_shift($parsed).ucfirst(array_shift($parsed));
            } else {
                    $page = array_shift($parsed);
            }
            if (empty($page)) {
                    $page = 'index';
            }
            $action = array_shift($parsed);
            if (empty($action)) {
                    $action = 'main';
            }
            if (empty($parsed)) {
                    $arguments = 0;
            } else {
                    $arguments = $parsed;
            }
            $target = SERVER_ROOT . '/controllers/' . $page . '.php';
            if (file_exists($target)) {
                    include_once $target;
                    $class = ucfirst($page) . '_Controller';
                    if (class_exists($class)) {
                            $controller = new $class;
                    } else {
                            die('la clase no existe');
                    }
            } else {
                    die('la pagina no existe');
            }
            $controller-&gt;$action($arguments);
    }
}
They are ok, but I would still do some things differently.


I would instead throw exceptions.
Instead of if else within your action, I would use a validator with rules.
Instead of using $_POST/$_GET directly, I would sanitize them and put it inside a Request class.
Error messages belongs to the view, so I would set $view-&gt;errors[]='message' or something like that.
Your routing class is not flexible. As a good example, you could take a look at the Silex framework.
Login_Controller should not exist. There might be Account_Controller with login_action or Authenticate_Controller with login_action. 


Usually a Controller is a group of actions with to execute specific stuffs. For example, Profile_Controller has view/edit/delete action. Within the controller you check the user roles, if someone can view/edit/delete the profile. In other frameworks, they use "Access Control List (ACL)" for this purpose.

Your linked tutorial is just for the basic understanding purpose, so please don't use it. Use a readily existing framework, since you wish to build the app and not the framework itself. You might end with modifying and changing your basic structures and implementing new functions instead of developing the features of your web application.