Solved

Encode and post xml in a hidden form field

Posted on 2009-03-30
4
966 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now