Is there a managed way to use $_POST and $_GET |
[eluser]WebMada[/eluser]
Hello! I used datas from a form. So I used the $_POST array to get them ($_GET does not exist for CI?) I wonder if there is a managed way to used it instead of calling directly this array?
[eluser]Maglok[/eluser]
There is. First $_GET is gotten from the query string, which is disabled by default because CI uses your uri bits. You can set it up again, but it is not really neccesary. It is in the user_guide somewhere. For POST, there is a more secure way in CI to grab it: Code: $this->input->post('name') It is in the input class (http://ellislab.com/codeigniter/user-gui...input.html) which is loaded by default.
[eluser]LifeSteala[/eluser]
Source: http://ellislab.com/codeigniter/user-gui...s/uri.html For $_GET you need to use: Code: $this->uri->segment([segment], [default_value]); Take for example: http://www.domain.com/controller/method/value1/value2/ To get value2 you do the following.. Code: $this->uri->segment(4, false); Note: the false is used if there is no value in segment 4 - example: http://www.domain.com/controller/method/value1/ Hope that helps!
[eluser]WebMada[/eluser]
Thanks about GET Curiosity: what about $_SESSION, i don't understand the user guide (http://ellislab.com/codeigniter/user-gui...sions.html) For ex, what is the CI equivalent of $_SESSION['name'] ???
[eluser]LifeSteala[/eluser]
Follow the comments in this code: Code: // Set session in native PHP How's that? Does that make sense?
|
Welcome Guest, Not a member yet? Register Sign In |