CodeIgniter Forums
URL after insert data - Printable Version

+- CodeIgniter Forums (
+-- Forum: CodeIgniter 4 (
+--- Forum: CodeIgniter 4 Support (
+--- Thread: URL after insert data (/thread-75982.html)

URL after insert data - Alexcodeig - 04-03-2020

Hey guys,

After insert data in DB, the system returns to home page. OK. But, the url stay like 'http://localhost/code4/home/save'. If I refresh the page (F5), the insertation is made again. I want return to 'http://localhost/code4/' only. Do someone help me?

Code from the 'Home' controller:

public function save(){
$usuarioModel= new UsuarioModel();

$dados= $this->request->getPost();

$request= $usuarioModel->save($dados);

echo view('base/header');
//echo view('menu');
echo view('home/index');
echo view('base/footer');


RE: URL after insert data - FoLez - 04-03-2020

Hello, use
PHP Code:
return redirect()->back(); 

you can read the documentation for the redirect function here