Answer the question
In order to leave comments, you need to log in
Why does Codeigniter return a GET array in the url in response to a form submission?
Hello. I'm learning the Codeigniter framework in practice and I ran into a problem, the solution of which I did not find on the Internet (probably, I didn't search well).
There is a form. I wrote the opening form tag itself in different ways, both through html and through php ( echo form_open('user/reg_user'); )
However, in response, I received the usual page refresh listing the data that was in the form via a GET request ( ala ?fio=ano&login=vasia%40gmail.com&password=qqq&city=kiev)
After I tried to "revive" another form on the next page through the same controller \ action, everything worked in both forms as it should, however, you can receive data in the model only by $this->input->get('some_data'); which means
The POST array is returned empty.
Help, please, with the given problem.
Answer the question
In order to leave comments, you need to log in
Reread the title of your question and the question itself. First, there is no such question. Secondly, it is not clear what is wrong :) Well, a lot of unnecessary details.
The page is updated and the parameters are added to the url, because the form does not have an action (url for submitting the form), so it exposes it by default in the current url. Well, the GET transfer method does its job - all parameters are passed through the URL, so the behavior is correct.
In the html code of the form write
<form action="<?=site_url('controller/action')?>" method="POST" name="myform">
...
$data = $this->input->post('myform');
// или
$data = $this->input->post_get('myform'); // в этом случае он сначала попытается найти данные в POST, а потом в GET
You didn't understand me, probably you need to be more specific :)
There is a form. There is a method of sending POST. There is an action, I wrote that I set it in 2 ways: through the form helper ( ( echo form_open('user/reg_user'); ) and as you said.
The data comes to my controller, which I specified, ONLY IN THE GET METHOD. POST comes empty
This is a problem that I can't solve.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question