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

[eluser]Aspi[/eluser]
Dear Forum Members!

I would like rebuild POST array again because i want filter this array.And then a make an sql insert.
But the rebuilded array format is not ok.
Code:
$data = array();

foreach($_POST as $key => $value){
if(!ereg("new",$key,$tomb)){
$key = preg_replace("(\d+)",' ',$key);
$data .= $key."=>".$value;

sql insert
Code:
UPDATE `iktatas` SET `0` = 'iktatoszam =>IKT-201104-001irany

or

UPDATE `iktatas` SET `Arrayiktatoszam` irany szallito iktattipus

thanks for your help
#2

[eluser]stuffradio[/eluser]
Can you give some sample data of what a post might look like?
#3

[eluser]InsiteFX[/eluser]
Why are you using $_POST and not CodeIgniters input->post ?
Code:
if(!ereg("new",$key,$tomb))

// should be:
if( ! preg_match("/new/",$key,$tomb))

InsiteFX
#4

[eluser]toopay[/eluser]
Since when we can use $_POST in CI???
#5

[eluser]InsiteFX[/eluser]
You can use $_POST but then you have no XSS etc protection unless you write your own!

You can use all of $_ arrays in CI there PHP.
But like I said you have no protection!!!!

InsiteFX
#6

[eluser]stuffradio[/eluser]
Since forever, but $this->input->post is better.
#7

[eluser]toopay[/eluser]
lol. I didnt notice that, its true. Oh, now i remember. When using CI 1.7.x, after failed using $_GET, i dont try other generic php like $_POST etc...
#8

[eluser]Aspi[/eluser]
Thanks everybody reply

public function index($formname,$form_pkey,$ID,$method)
{
$data = array();
foreach($_POST as $key => $value){
if(!ereg("new",$key,$tomb)){
$key = preg_replace("(\d+)",'',$key);
$data[$key] = $value; ==> this is the right answer
}}
if($method == "update")
$this->update($formname,$form_pkey,$ID,$data);
}

if replace $_POST to $this->...->post is ok?




Theme © iAndrew 2016 - Forum software by © MyBB