Exemplo n.º 1
0
 public function login()
 {
     $error_login = '';
     if (isset($_POST['login'])) {
         $error_login = '';
         $username = $_POST['login_username'];
         if ($this->checkEmply($username, 'username') != '') {
             $error_login .= '<div class="alert alert-danger">' . $this->checkEmply($username, 'username') . '</div>';
         }
         $password = $_POST['login_password'];
         if ($this->checkEmply($password, 'password') != '') {
             $error_login .= '<div class="alert alert-danger">' . $this->checkEmply($password, 'password') . '</div>';
         }
         if ($error_login == '') {
             $model = new ModelUser();
             $id_user = $model->checkAccount($username, $password);
             if ($id_user) {
                 $_SESSION['user'] = $id_user;
                 header('Location: profile');
                 exit;
             } else {
                 $error_login .= '<div class="alert alert-danger">Username or password not correct</div>';
             }
         }
     }
     $view = new View("index.php");
     $view->set('error_login', $error_login);
     $view->output();
 }