$_SESSION['user']['id']])->fetch(); return new Response(View::render('account.twig', [ 'user' => $user, ])); } #[Route(path: '/account', methods: ['POST'])] public function accountSave(Request $request): Response { $username = $request->get('username'); $email = $request->get('email'); if ($request->get('password')) { $password = password_hash($request->get('password'), PASSWORD_DEFAULT); DB::query( 'update users set username=:username, email=:email, password=:password where id=:id', [ 'username' => $username, 'email' => $email, 'password' => $password, 'id' => $_SESSION['user']['id'], ] ); } else { DB::query( 'update users set username=:username, email=:email where id=:id', [ 'username' => $username, 'email' => $email, 'id' => $_SESSION['user']['id'], ] ); } $_SESSION['user']['username'] = $request->get('username'); return new RedirectResponse(Router::generate('user.account')); } }