JavaScript-ask PHP to get post data in bulk and save the database

Source: Internet
Author: User
Keywords Php javascript
Front-end post data come here! There are about 30 data, all in JSON format, so that my background PHP can be batched to get, parse out! and save it to the database? Ask for advice, big wet ' s .....

If each write $_post[""; too unreasonable;;;

Reply content:

Front-end post data come here! There are about 30 data, all in JSON format, so that my background PHP can be batched to get, parse out! and save it to the database? Ask for advice, big wet ' s .....

If each write $_post[""; too unreasonable;;;

By foreach ($_POST as $key => $value) {} looping through all the parameters and doing something, you can combine the parameters and persist them to the database in the appropriate way.

30 data is stored in a JSON packet, and then you receive the time to parse the array with unserialize, that is, Key=>value, and then you loop down into SQL statements.

Does the post data not be verified?

Json_decode ()

You can use File_get_contents ("Php://input") to receive requests, and then perform decode processing

  • Related Article

    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.