CodeIgniter Forums
Why NOT use $_POST directly? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Why NOT use $_POST directly? (/showthread.php?tid=42743)

Pages: 1 2


Why NOT use $_POST directly? - El Forum - 06-17-2011

[eluser]RJ[/eluser]
The CI way is to grab post params through the input class $this->input->post(). I ask you, why not simply use $_POST?

Thanks


Why NOT use $_POST directly? - El Forum - 06-17-2011

[eluser]osci[/eluser]
$this->input->post() calls _fetch_from_array which checks for $xss_clean === TRUE and uses security class if needed.

You can always use $_POST but you would have to do this stuff yourself.


Why NOT use $_POST directly? - El Forum - 06-17-2011

[eluser]RJ[/eluser]
That's what I thought. Thanks @osci


Why NOT use $_POST directly? - El Forum - 06-20-2011

[eluser]Aken[/eluser]
It also will default to an empty string if that particular $_POST variable doesn't exist, which can be handy (but don't be lazy when you code, mkay).


Why NOT use $_POST directly? - El Forum - 06-20-2011

[eluser]theprodigy[/eluser]
I believe it defaults to the boolean FALSE, not an empty string.


Why NOT use $_POST directly? - El Forum - 06-20-2011

[eluser]InsiteFX[/eluser]
@theprodigy, Correct!

InsiteFX


Why NOT use $_POST directly? - El Forum - 06-20-2011

[eluser]theprodigy[/eluser]
YAY!! What did I win?? :-D


Why NOT use $_POST directly? - El Forum - 06-20-2011

[eluser]InsiteFX[/eluser]
A BOOLEAN TRUE LOL!


Why NOT use $_POST directly? - El Forum - 06-21-2011

[eluser]theprodigy[/eluser]
lol


Why NOT use $_POST directly? - El Forum - 06-21-2011

[eluser]Aken[/eluser]
Drat, you're right. I haven't dealt with any non-required POST fields in a while, haha. My mistake.