IT Community - Software Programming, Web Development and Technical Support

How can I send variables from a PHP script to another URL using POST without using fo

This is a discussion on How can I send variables from a PHP script to another URL using POST without using fo within the PHP Programming forums, part of the Web Development category; How can I send variables from a PHP script to another URL using POST without using forms and hidden variables? ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 07-24-2007, 12:10 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Question How can I send variables from a PHP script to another URL using POST without using fo

How can I send variables from a PHP script to another URL using POST without using forms and hidden variables?


I want to know this ASAP...Plz help
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-24-2007, 01:21 AM
vijayanand vijayanand is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 293
vijayanand is on a distinguished road
Default Re: How can I send variables from a PHP script to another URL using POST without usin

please visit the site for the same question.

http://www.discussweb.com/php/2202-s...hout-form.html
__________________

J.Vijayanand
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-24-2007, 02:58 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Default Re: How can I send variables from a PHP script to another URL using POST without usin

You can open an HTTP socket connection and send HTTP POST commands. Here is
an example :

<?
// Generate the request header
$ReqHeader =
"POST $URI HTTP/1.1\n".
"Host: $Host\n".
"Content-Type: application/x-www-form-urlencoded\n".
"Content-Length: $ContentLength\n\n".
"$ReqBody\n";

// Open the connection to the host
$socket = fsockopen($Host, 80, &$errno, &$errstr);
if (!$socket)

$Result["errno"] = $errno;
$Result["errstr"] = $errstr;
return $Result;
}
$idx = 0;
fputs($socket, $ReqHeader);
while (!feof($socket))

$Result[$idx++] = fgets($socket, 128);
}
//-------------------------------------------
?>


Or you can use the cURL extensions for PHP (cURL and libcurl). Once you build it and compile their support into PHP, it is fairly easy to do posting stuff (even over https):


<?
$URL="www.mysite.com/test.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://$URL");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "Data1=blah&Data2=blah");curl_exec ($ch);
curl_close ($ch);
?>


This will have the net effect of posting your data to the $URL site, without any header hacking.

You can also do other nifty things with cURL, like retrieve the HTML into variables and scrape through it for neat functionality.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/php-programming/2583-how-can-i-send-variables-php-script-another-url-using-post-without-using-fo.html
Posted By For Type Date
Land Refinance - refinance jersey land, land home refinance This thread Refback 11-15-2007 01:16 PM

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get the Post values without using Server Variables? senraj PHP Programming 6 10-17-2007 11:31 PM
How to send data from servlet to javascript variables Pvinothkumar HTML, CSS and Javascript Coding Techniques 0 10-09-2007 11:05 PM
Can an html and Java script be separated and the script placed in the cgi-bin? Pvinothkumar HTML, CSS and Javascript Coding Techniques 1 09-13-2007 06:11 AM
How to send variables from a PHP script to another URL, using POST without using form oxygen PHP Programming 1 07-26-2007 03:25 AM
How to Send Email from a PHP Script Using SMTP Authentication? Sabari PHP Programming 1 07-20-2007 05:42 AM


All times are GMT -7. The time now is 02:42 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0