CodeIgniter Forums
unsetting $this->input->post() value - 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: unsetting $this->input->post() value (/showthread.php?tid=51694)



unsetting $this->input->post() value - El Forum - 05-14-2012

[eluser]veledrom[/eluser]
Hi,

I wish to accomplish this but no luck: unset($this->input->post('text_password'));

Is there any other way?

Thanks


unsetting $this->input->post() value - El Forum - 05-14-2012

[eluser]Matalina[/eluser]
Try this:
Code:
$posts = $this->input->post();
unset($posts['text_password']);

You are trying to unset on a method.



unsetting $this->input->post() value - El Forum - 05-14-2012

[eluser]CroNiX[/eluser]
@Matalina That would only unset it in the new variable, $posts.

The only way to actually wipe out a post variable is on the actual global $_POST array, which is where CI gets the value from if you use input::post().

Code:
unset($_POST['text_password']);



unsetting $this->input->post() value - El Forum - 05-14-2012

[eluser]Matalina[/eluser]
I made an assumption that the OP was using all the post information elsewhere. My bad in assuming.

Either way he was unseeting a method and unset only works on variables.


unsetting $this->input->post() value - El Forum - 05-14-2012

[eluser]veledrom[/eluser]
Code:
$posts = $this->input->post();
unset($posts['text_password']);

That will do because I'll be passing $posts to a session so no need to worry about what I have left in $this->input->post()

Thanks