We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

How to remove url after submit form

Hi all I wan to remove url https://duythien.dev/eduapps/admin/hososinhvien/edit/7 gold https://duythien.dev/eduapps/admin/hososinhvien/ i using return $this->dispatcher->forward(array('action' => 'index')); but not remove url above, how to hint


use $this->response->redirect()


but $this->flash->success("Đã xóa thành công"); not working


When using redirect, you must use session flash. $this->flashSession->success("Đã xóa thành công");

edited Mar '14

I using session flash. but working

if ($this->uploadImg($request->getPost('MaSV')) == true) {
                    if($Hososinhvien->update()) {
                    $this->flashSession->success("Cập nhật thành công: ".$Hososinhvien->MaSV);
                    return $this->dispatcher->forward(array('action' => 'index'));
                    //return $this->response->redirect('admin/hososinhvien');



The problem is that you don`t understand, how forward works.

Forward forwards your action to another action into SERVER SIDE. It means, that you are still doing same request, which is your current form POST request. To see flash message you need to do redirect instead of forward, because flash message is stored in session, and it gets removed and attached to get method after each request from user client(browser).

Easily forward works like: POST request -> action(with post request url) -> forward action(url is still from post request) -> response to user browser And redirect works like: POST request -> action(with post request url) -> response to user browser(redirect url)