TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-03-2011, 09:38 PM   #1 (permalink)
The Acquainted
 
buildakicker's Avatar
 
Join Date: Jan 2008
Posts: 119
Thanks: 21
buildakicker is on a distinguished road
Application Error Send Request in Form, Get XML Back in Variable, Compare and Send Again...

Hello all,

I have been digging away at this for a couple days, but am not getting any closer to a solution...

I have a url (domain/parse.php) that I send some form data to and get a XML response on the page, in the body. From my form on domain2/form.php, I would like to get that response into a variable and pass it to another little function to compare the data. I am striking out at getting the XML from the parse.php page...

Any ideas or thoughts on how to get this?
__________________
SkiLeases.com
buildakicker is offline  
Reply With Quote
Old 05-04-2011, 01:20 PM   #2 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

you can use the curl library:
php Code:
//in domain2/form.php

//Initialize the Curl session
$ch = curl_init();

//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//Set the URL
curl_setopt($ch, CURLOPT_URL, "http://domain/parse.php");

//Execute the fetch
$data = curl_exec($ch);

//Close the connection
curl_close($ch);

//then you can handle the XML
$xml = new SimpleXMLElement($data);
tony is offline  
Reply With Quote
Old 05-05-2011, 07:34 PM   #3 (permalink)
The Acquainted
 
buildakicker's Avatar
 
Join Date: Jan 2008
Posts: 119
Thanks: 21
buildakicker is on a distinguished road
Default

Thanks for the reply. I have gotten it to work with FSOCKOPEN. We don't have CURL on the PHP instal, but that was one of my initial thoughts... Thanks again for a well writen out example.
__________________
SkiLeases.com
buildakicker is offline  
Reply With Quote
Old 05-05-2011, 08:10 PM   #4 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

Great! my knowledge in socket programming has been dwindling down... (need to retry that) So kudos for you.

But you can also use streams, like using a combination of file or file_get_contents with stream contexts (stream_context_create).
tony is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 10:44 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design