Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with php / xml form

Status
Not open for further replies.

alancuth

Technical User
Mar 29, 2010
1
PT
hi,

i have the following code

Code:
<?php 

$XPost=
'<?xml version="1.0" encoding="UTF8" ?>
<Username>my username</Username>
<Password>my password</Password>
<DestinationID></DestinationID>
<ResortID></ResortID>
<HotelID></HotelID>
<RoomID></RoomID>
<Meal></Meal>
<CheckIn>2010-04-07</CheckIn>
<CheckOut>2010-04-15</CheckOut>
<Rooms>1</Rooms>
<Adults>1</Adults>
<Children>0</Children>
<Infants></Infants>
<SortBy>Price</SortBy>
<SortOrder>ASC</SortOrder>
</GethotelAvail>';
$ch =
curl_init('[URL unfurl="true"]http://www.my_url?'.'xml='.urlencode($XPost))[/URL]
;
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_NOBODY, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$responseInfo=curl_getinfo($ch);
curl_close($ch);
echo $response;

?>


i would like to be able to place a form on my website that will update the params above (except username and password) and return the search results based on the users form input.

any help greatly appreciated.

al
 
[0] The ingredients are these.
[0.1] On the page, you can place text boxes named DestinationID, ResortID, etc...
[0.2] When the form is submitted, you grap the submited data by checking $_POST['DestinationID'], $_POST['ResortID], etc...
[0.3] From the data grapped, you escape the xml entities by replacing them with the escaped form; & to &, > to >, etc...
[0.3] With those obtained, you build the $XPost, which is afterall a string only. In particular, the interpolation helps you make the build visually friendly.

[1] For an application of more complexity and for longer-term maintenance, I could easily perceived it in this form.
[1.1] An xml document quite involatile storing Uusername and Password.
[1.2] Another template xslt document with all the "unknown" (DestinationID, ResortedID, etc...) in the form of global parameters.
[1.3] Call up the DOMDocument to load up the xml document. And then the xsltprocessor. Pass the results of $_POST[] to xsltprocessor as parameters using setParameter() method.
[1.4] Use transformToXml() to obtain the desired $XPost.

That's above it, the approaches.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top