I'm a relative newbie to PHP and a total newbie to XML, but here's my task:
I have a page that accepts some input from the user, then creates a message containing a header and and XML block to send to a third party. Their CGI parses the XML, uses the $txtName value contained to query a databases, and sends me an XML block containing the results.
Here's what I have so far:
<?php //I do have the 'short tags' option set to OFF in php.ini
$header = "GET /bin/some.cgi HTTP/1.1 \n Host:ahost.com \n Content-type:text/xml Content-length:70";
$xml_block = "<?xml version=\"1.0\"> <element>data</element> <name>$txtName</name>";
$message = $header.$xml_block;
print("
<form action=\"http://ahost.com/bin/some.cgi?$message\" method=\"get\">
Enter name:
<input type=\"text\" name=\"txtName\">
<input type=\"submit\" value=\"Go\" name=\"GoButton\">
</form>
");
?>
My questions:
1. How picky is the receiving server going to be about newlines, spaces,etc in the message I send?
- When I view just the straight php part (commenting out the form), the header looks fine, but the $xml_block is set to
<?xml version="1.0"> data
Why is it not accepting this as a long text string? It's like PHP is trying to parse the XML for me, even though I haven't told it to.
- And third, is this in general the right approach, or am I missing something?
Thanks for any help you can offer.
Sheila