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)))))));