A
A
Alexey Verkhovtsev2016-11-04 03:05:24
CodeIgniter
Alexey Verkhovtsev, 2016-11-04 03:05:24

How to make a correct redirect in CodeIgniter?

Hello everyone, such a question, I have a Pages controller, it has a view method that connects the desired view (taken from the official documentation), there is a Request controller that is responsible for requests from various forms on the site. When I go to the contact-us page, then my URL looks like this index.php/pages/view/contact-us, the form action leads to request/contact_us_request, in it I check the validity of the form, etc. but if i click on submit, it navigates and my url becomes index.php/request/contact_us_request, how do i make it redirect regardless of the success of field validation to my original controller? Redirect is not suitable, because Errors for fields are lost... How could it be that everything should have been done in the view method?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Egor, 2016-11-04
@egormmm

Frankly, you misunderstood how Codeigniter works. I would re-read the docs.
If you want some controller to open after submitting the form, then there are several options:
1. Send data to it
2. Make a redirect to it with saving the necessary data, for example, in the session (flashdata).
Choose what suits you best.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question