PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old July 1st, 2002, 04:51 PM
rhodesiascout rhodesiascout is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 rhodesiascout User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
passing an xml string to a file

I have created (with PHP), a string which is composed of xml.

E.g.

$xmlstring=
<?"xml version="1.0" encoding="ISO-8859-7"?>
<Request>
<id>name</id>
<Type>00</Type>
<Trans>3838384859</Trans>
<Amount>5045</Amount>
</Request>" ;

Now, i want to pass this string to an .asp file.
However, i dont want to write to the file using fwrite($fopen,$xmlstring)
because that would erase the contents of the .asp file.
I want to send it as a string so that the .asp file can take all the data from the string and do different things with it.

Is there a function in PHP which does the same as "XMLHttp.send($xmlstring)" does in VBScript?

Its the same when you send a form using POST to another page.You dont write to that page, you just pass some values to it.

Reply With Quote
  #2  
Old July 1st, 2002, 06:15 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: passing an xml string to a file

Well, the XMLHttp.send method in VBScript is going to do a POST or GET depending on what you specify in xmlhttp.Open...here is a function you can use that will do the same thing in PHP:

php Code:
Original - php Code
  1. <?
  2. /* sendToHost
  3. * ~~~~~~~~~~
  4. * Params:
  5. *   $host - Just the hostname.  No http:// or /path/to/file.html portions
  6. *   $method - get or post, case-insensitive
  7. *   $path - The /path/to/file.html part
  8. *   $data - The query string, without initial question mark
  9. *   $useragent - If true, 'MSIE' will be sent as the User-Agent (optional)
  10. *
  11. * Examples:
  12. *   sendToHost('www.google.com','get','/search','q=php_imlib');
  13. *   sendToHost('www.example.com','post','/some_script.cgi',
  14. *              'param=First+Param&second=Second+param');
  15. */
  16. function sendToHost($host,$method,$path,$data,$useragent=0) 
  17. {
  18.     // Supply a default method of GET if the one passed was empty
  19.     if (empty($method))
  20.         $method = 'GET';
  21.     $method = strtoupper($method);
  22.     $fp = fsockopen($host,80);
  23.     if ($method == 'GET')
  24.         $path .= '?' . $data;
  25.     fputs($fp, "$method $path HTTP/1.1n");
  26.     fputs($fp, "Host: $hostn");
  27.     fputs($fp, "Content-type: application/x-www-form-urlencodedn");
  28.     fputs($fp, "Content-length: " . strlen($data) . "n");
  29.     if ($useragent)
  30.         fputs($fp, "User-Agent: MSIEn");
  31.     fputs($fp, "Connection: closenn");
  32.     if ($method == 'POST')
  33.         fputs($fp, $data);
  34.  
  35.     while (!feof($fp))
  36.         $buf .= fgets($fp,128);
  37.     fclose($fp);
  38.     return $buf;
  39. }
  40. ?>


Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > passing an xml string to a file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway