tags:

views:

19

answers:

1

I have a dictionary in jsons form like this:

$user = "{ name: Mary , born: 1963, money: 213 }";

I need to pass it throught this field:

<input type="hidden" name="custom" value="" >

and then insert it in the db:

INSERT INTO user ( name, born, money ) VALUE ( $name, $born, $money )

How can I do that ?

+3  A: 

As far as putting it in a hidden input is concerned, it is just text. So do with it what you would do with any other text. (i.e. run htmlspecialchars over it and drop it in there).

Then use PHP's JSON functions to turn it into a data structure then you can pick the bits you care about out of and stuck them into a prepared SQL statement.

David Dorward