Page 1 of 1

JSON

Posted: Fri Jul 23, 2010 10:42 am
by spacebiscuit
Some of you have ben helping me with a solve a problem when passing user input data via a form:

viewtopic.php?f=1&t=119028&p=617018#p617018

As has been advised, serilization is a secuity risk so I'm looking into the json_encode method. If I use urlencode and then json_encode prior to sending the receiving script outputs the variable as:

["1234567890","1234567890","1234567890","end"]

If I use json_decode this empties the variable and I got no putput. So how do I put the data back into an indexed array?

Thnaks in advance,

Rob.

Re: JSON

Posted: Fri Jul 23, 2010 10:51 am
by AbraCadaver
Is there a reason why you don't just assign the array to a session var?

Re: JSON

Posted: Fri Jul 23, 2010 10:56 am
by spacebiscuit
Yes, because the form is sent to a 3rd party where processing is done. After this has been completed the page redirects back to my script where I pick up the variables. I tried intially with the sessions but they do not pass once the re-direction occurs.

Rob.

Re: JSON

Posted: Fri Jul 23, 2010 11:24 am
by AbraCadaver
OK, how about a series of hidden vars like:

Code: Select all

foreach($mydata as $key => $value) {
   echo '<input type="hidden" name="mydata['.$key.']" value="'.$value.'">';
}