Link to home
Start Free TrialLog in
Avatar of ncw
ncw

asked on

Encode and post xml in a hidden form field

I'm posting cxml via http in a hidden form field. Before posting I'm encoding the cxml in php using utf8_encode and urlencode as shown below. The problem seems to be that the encoding replaces spaces in the tags with a plus sign(+) and when the receiving software tries to decode it fails, and I believe it's because of these plus signs in the tags.

Any ideas please? I don't want to use curl function btw.  
urlencode(utf8_encode($cxml))

Open in new window

Avatar of marchent
marchent
Flag of Bangladesh image

After encoding, just replace only the plus(+) with space before submit.
$cxml = urlencode(utf8_encode($cxml))
$cxml = preg_replace('/\+/', ' ', $cxml);

Open in new window

Avatar of ncw
ncw

ASKER

Do I need to be using urlencode, does the browser automatically apply encoding during the form submission?
I don't sure about this, but better to use urlencode when there is a chance to escaping.
ASKER CERTIFIED SOLUTION
Avatar of ncw
ncw

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial