• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1006
  • Last Modified:

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

0
ncw
Asked:
ncw
  • 2
  • 2
1 Solution
 
marchentCommented:
After encoding, just replace only the plus(+) with space before submit.
$cxml = urlencode(utf8_encode($cxml))
$cxml = preg_replace('/\+/', ' ', $cxml);

Open in new window

0
 
ncwAuthor Commented:
Do I need to be using urlencode, does the browser automatically apply encoding during the form submission?
0
 
marchentCommented:
I don't sure about this, but better to use urlencode when there is a chance to escaping.
0
 
ncwAuthor Commented:
I've now solved this issue. The urlencode function was not required, but applying htmlentities to the form post url and to the cxml being posted was necessary.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now