JSON

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

JSON

Post 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.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: JSON

Post by AbraCadaver »

Is there a reason why you don't just assign the array to a session var?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: JSON

Post 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.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: JSON

Post 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.'">';
}
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply