?
Solved

Encode and post xml in a hidden form field

Posted on 2009-03-30
4
Medium Priority
?
975 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

649 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