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



$this->input->post problem - El Forum - 07-11-2008

[eluser]Mitja B.[/eluser]
Code:
foreach($this->input->post => $vrednost)
{
   if (!is_array($this->input->post($kljuc)))
   {
    $this->input->post($kljuc) = htmlspecialchars($this->input->post($kljuc));
   }
}

i want to use htmlspecialchars in all $this->input->post but i get this warning

Parse error: syntax error, unexpected T_DOUBLE_ARROW in C:\HTTPSERVER\wwwroot\bewoop\system\application\controllers\happening.php on line 22


$this->input->post problem - El Forum - 07-11-2008

[eluser]Bramme[/eluser]
$this->input->post is not a variable and certainly not an array, so you can't loop through it with a foreach.

If you use validation, you could simply use this:

$rules[$kljuc] = 'htmlspecialchars';


$this->input->post problem - El Forum - 07-11-2008

[eluser]Mitja[/eluser]
what do you want to do with this?


$this->input->post problem - El Forum - 07-11-2008

[eluser]Mitja B.[/eluser]
Hi, thx for answer.

With $_POST i am using

Code:
foreach($_POST as $key => $value)
{
    if (!is_array($_POST[$key]))
    {
        $_POST[$key] = htmlspecialchars($_POST[$key]);
    }
}

but i want to make this for $this->input->post() becouse in CI i am using $this->input->post() instead of $_POST.

Is it possible to make this?


$this->input->post problem - El Forum - 07-11-2008

[eluser]loathsome[/eluser]
Just use the validation library, validate data BEFORE it goes into processing, and throw the entire array into your database (or whatever you're going to do with it)


$this->input->post problem - El Forum - 07-11-2008

[eluser]Mitja B.[/eluser]
i am already using form validation or there is any other validation?


$this->input->post problem - El Forum - 07-11-2008

[eluser]Mitja B.[/eluser]
Did you mean escape it with $this->db->escape()

Thx