Welcome Guest, Not a member yet? Register   Sign In
problem with input->post
#1

[eluser]taschentuch[/eluser]
hi guys i rewrite my old code with CI but i have a problem

my old code:

Code:
foreach($_POST as $k=>$v)
if($v != "uid" && $k != "uid")
if(in_array($k, $arr2))
$neu .= "$k|";
$strr = substr($neu,0,-1);

and now CI:

Code:
function setpermission()
{
$arr2 = $this->tank_auth->get_permissions_details();
foreach($this->input->post() as $k=>$v)
if($v != "uid" && $k != "uid")
if(in_array($k, $arr2))
$neu .= "$k|";

$strr = substr($neu,0,-1);
echo $strr;
}

my problem is now

foreach($this->input->post() as $k=>$v)

does not work...


Quote:A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: admin/User.php
Line Number: 34

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: neu
Filename: admin/User.php
Line Number: 39


how can i do this ?

thx
#2

[eluser]Twisted1919[/eluser]
No need to use $this->input->post() .
Use $_POST directly , bc will work . Don't forget to sanitize your data after that .
#3

[eluser]khagendra[/eluser]
Here is an example for fetching the array values form view. Hope this will help you and you will be understand easily.

-- The controller (example.php)--
Code:
class Example extends Controller {
    
    function Example()
    {
        parent::Controller();
        $this->load->helper('url');
        
    }
    
    function index()
    {
        $this->load->view('v_example');
    }
    
    function show()
    {
        foreach($_POST['name'] as $name)
        {
            echo $name.'<br>';
        }
    }
}

-- The view (v_example.php)--
Code:
&lt;form action="&lt;?=site_url('example/show')?&gt;" method="post"&gt;
&lt;input type="text" name="name[]" value="khagendra" /&gt;
&lt;input type="text" name="name[]" value="khagendra shah" /&gt;
&lt;input type="text" name="name[]" value="khagendra pd shah" /&gt;
&lt;input type="submit" name="submit" value="Submit" /&gt;

&lt;/form&gt;
#4

[eluser]taschentuch[/eluser]
ah thx ii do it with the "array" thx khagendra




Theme © iAndrew 2016 - Forum software by © MyBB