Solved

Encode and post xml in a hidden form field

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…

911 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

22 Experts available now in Live!

Get 1:1 Help Now