?
Solved

Encode and post xml in a hidden form field

Posted on 2009-03-30
4
Medium Priority
?
979 Views
Last Modified: 2012-05-06
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
Comment
Question by:ncw
  • 2
  • 2
4 Comments
 
LVL 13

Expert Comment

by:marchent
ID: 24022945
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
 
LVL 1

Author Comment

by:ncw
ID: 24026777
Do I need to be using urlencode, does the browser automatically apply encoding during the form submission?
0
 
LVL 13

Expert Comment

by:marchent
ID: 24027879
I don't sure about this, but better to use urlencode when there is a chance to escaping.
0
 
LVL 1

Accepted Solution

by:
ncw earned 0 total points
ID: 24029961
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month16 days, 15 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question