Welcome Guest, Not a member yet? Register   Sign In
Array
#1

[eluser]ealonw[/eluser]
How can I turn post variables into an array?

$this->input->post('fname');
$arg['fname'] = ?
$this->input->post('lname');
$arg['lname'] = ?
$this->input->post('email');
$arg['email'] = ?

am i doing this right?
#2

[eluser]onejaguar[/eluser]
If you aren't using xss_clean() you can just use the $_POST array.

If you are using xss_clean() you can set
Code:
$config['global_xss_filtering'] = TRUE;
In application/config/config.php and it will run xss_clean() on everything in the $_POST array, or you can do a one off:
Code:
$_POST['email'] = $this->input->xss_clean($_POST['email')
#3

[eluser]ealonw[/eluser]
would i be able to do something like this in CI..?

$fname = $this->input->post(’fname’);
$arg[’fname’] = $fname;
$lname = $this->input->post(’lname’);
$arg[’lname’] = $lname;
$email = $this->input->post(’email’);
$arg[’email’] = $email;

and then do

foreach($arg as $key=>$value)...

It seems the $arg[''] = $whatever;
doesnt work at all... why?
#4

[eluser]Jamie Rumbelow[/eluser]
If you want to loop through, just use this:

Code:
foreach ($_POST as $key => $value) {

$arg[$key] = $value;

}

Remember - the $_POST array functions just as a regular array does.




Theme © iAndrew 2016 - Forum software by © MyBB