Solution for passing values in arrays on the page

Source: Internet
Author: User
A. php has a two-dimensional data, which is passed to B. phpa. phpHTMLcode & lt; formname = & quot; loadConfirm & quot; method = & quot; post & quot; action = & quot; B. php? M = 1 & qu array values on the page
A. php has a two-dimensional data, which is passed to B. php.
A. php
HTML code
  

B. php
If ($ _ GET ['M']) {
Print_r ($ _ POST ['data']);
SaveData ($ _ POST ['data']); // A database insertion function
}
?>
Through this method, the $ _ POST ['data'] is changed to a three-dimensional array. how can this problem be solved ???

------ Solution --------------------
Serialization

Serialize

Escape
------ Solution --------------------
Discussion

Reference:

Sorry, I don't understand. Please clarify

------ Solution --------------------


Upload the serialized value to the hidden domain and pass it to B. php for processing. on the B. php side, unserialize ($ _ POST ['data']) // is an array,

Serialize () returns a string. for details, refer to the manual.
------ Solution --------------------
If ($ _ GET ['M']) {
Print_r (unserialize ($ _ POST ['data']); // This only verifies data integrity.
SaveData (unserialize ($ _ POST ['data']); // you can pass the array
}

------ Solution --------------------


Addslashes escape is required for serialization.

When the value is passed, the default value is usually, or the program unifies the addslashes.

To see the effect, the server removes several escape characters as needed.
PHP code
$arr    = array("'", "\\");print_r(unserialize(stripslashes(stripslashes(addslashes(addslashes(serialize($arr)))))));

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.