Mangled Data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



PHP 7.2.9

An incoming JSON string is not acted on in this script; just passed
through to the next script. I do the following, where 'trans' is a
JSON string:  (ie result of JavaScript stringify() command) 

if (isset($_POST['trans']))
{
 $ord_jdata = $_POST['trans'];

....

<form method="POST" name="order" id="order" onSubmit="finished()"
action="....>
<input type="hidden" name="trans-1" id="trans-1" value= <?php echo
$ord_jdata ?> >
</form>

When this is submitted the data stored in form.trans-1 is NOT the same
as the data in $ord.jdata, specifically the following component, as
shown by the Firefox devtools | inspector command no longer has the
escape \ before the " character. 

The JSON data contains a string (part of an array) that, when received
is:
... ,\"name\":'"some data is found here\", ... 
but this is stored in the form input field as:
... ,\"some" data="" is="" found="" here=\",

which is not at all the same thing.  Apparently the spaces within the
string are being treated as delimiters for null parameters.  

Experimenting, I can do a valid/correct json_decode on the incoming
data; it just doesn't copy properly.

After reading the JSON part of the PHP manual I can't see why this
should be so and I suspect that I have run over some constarint on
data formatting but I don't see it.

Can anyone help??

Thanks in advance.

John
============



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux