$_POST['var'] isset but $this->input->post('var') returns FALSE - 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: $_POST['var'] isset but $this->input->post('var') returns FALSE (/showthread.php?tid=7502) |
$_POST['var'] isset but $this->input->post('var') returns FALSE - El Forum - 04-11-2008 [eluser]ScottBruin[/eluser] I'm using jQuery's $.load ajax function to send some POST variables. Sometimes, my variable q is set to ''. (That is, I send a jquery object { 'q': '' } with the $.load function. When I try to load $this->input->post('q') with CI, it returns FALSE. However, if I do something like below, I am told that $_POST['q'] is set Code: if (isset($_POST['q'])) { echo 'post is set'; } According to the user guide for <b>$this->input->post()</b>: Quote:The function returns FALSE (boolean) if the item you are attempting to retrieve does not exist.Source: http://ellislab.com/codeigniter/user-guide/libraries/input.html What exactly "if the item...does not exist" means is ambiguous at best. For me, I think, I'm trying to retrieve the $_POST item 'q' and it does exist though it has no value. Also, I just created a test for this without any jQuery involved and the behavior is the same. Here's the controller I used: Code: <?php $_POST['var'] isset but $this->input->post('var') returns FALSE - El Forum - 04-11-2008 [eluser]Seppo[/eluser] Well... you should use !== instead of !=, because PHP evaluates '' == FALSE as true $_POST['var'] isset but $this->input->post('var') returns FALSE - El Forum - 04-12-2008 [eluser]ScottBruin[/eluser] Thanks Seppo..did not know that. |