How does php obtain the data in json transmitted by post! The above is the json data transmitted in post mode;
How does php receive and save the data to the database?
Please advise !!
Reply to discussion (solution)
$ _ POST
If the data received by php is decoded using json_decode, if it is not UTF-8 encoded, it must be converted to UTF-8.
If no value exists in $ _ POST, use file_get_contents ('php: // input') to receive the message (as described in the manual)
I am a newbie. could you give me an example!
$ Arr = json_decode ($ _ POST ['json'], true); print_r ($ arr); it's an array. it's easy to save the database.
I did my research and got it done. The post cannot get the data, and the input is used.
$ Data = file_get_contents ("php: // input"); // get json data $ data = json_decode ($ data, TRUE ); // format $ a1 = $ data ['form']; $ a2 = $ data ['entry '] ['Field _ 1']; $ sql1 = "insert into xxx (a1, a2) values ('$ A1',' $ a2 ')";