开发者

How trasmit a dictionary in JSON form

开发者 https://www.devze.com 2022-12-31 02:35 出处:网络
I have a dictionary 开发者_运维问答in JSON form, like this: $user = \"{ name: Mary , born: 1963, money: 213 }\";

I have a dictionary 开发者_运维问答in JSON form, like this:

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

I need to pass it through this field:

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

and then insert it in the database:

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消