CodeIgniter Forums
Is it impossible to redirect back or to another route with POST method request? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: Is it impossible to redirect back or to another route with POST method request? (/showthread.php?tid=77883)



Is it impossible to redirect back or to another route with POST method request? - mrardiyansyah - 10-31-2020

I got an error when I wanted to redirect back with a 404 error. So I created a route 1 url with 3 different HTTP requests. I want to redirect with the POST request method but the return one is always GET method request. Is it impossible to redirect back using the POST method?


RE: Is it impossible to redirect back or to another route with POST method request? - includebeer - 11-02-2020

Have you try this?
PHP Code:
return redirect()->back()->withInput()->with('errors'$this->validator->getErrors()); 

Can you show what your tried and what version of CI, 3 or 4?


RE: Is it impossible to redirect back or to another route with POST method request? - mrardiyansyah - 11-03-2020

(11-02-2020, 03:04 PM)includebeer Wrote: Have you try this?
PHP Code:
return redirect()->back()->withInput()->with('errors'$this->validator->getErrors()); 

Can you show what your tried and what version of CI, 3 or 4?
I've tried this method with a slightly different code. but the 404 File not Found error always appears. Because I'm doing a redirect from the PUT request routes back to the route with POST request.

My Code : 

PHP Code:
$validation = \Config\Services::validation():
return 
redirect()->back()->withInput()->with('validation'$validation);