Solved

Encode and post xml in a hidden form field

Posted on 2009-03-30
4
971 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
The viewer will learn how to count occurrences of each item in an array.
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.

724 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