How does php obtain the data in json transmitted by post!

Source: Internet
Author: User
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 ')";

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.