User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 403,212 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,747 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 12992 | Replies: 8
Reply
Join Date: Sep 2004
Posts: 10
Reputation: laxy_m is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
laxy_m laxy_m is offline Offline
Newbie Poster

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

  #1  
Sep 28th, 2004
Hi!!
Please guide me. How can I send variables from a PHP script to another URL using POST without using forms and hidden variables?

Thanks
Laxy
Last edited by cscgal : Apr 6th, 2006 at 9:15 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2003
Location: Toronto, Canada
Posts: 354
Reputation: Gary King will become famous soon enough Gary King will become famous soon enough 
Rep Power: 6
Solved Threads: 5
Colleague
Gary King's Avatar
Gary King Gary King is offline Offline
PHP/vBulletin Guru

Re: How can I send variables from a PHP script to another URL using POST without.........

  #2  
Sep 28th, 2004
I don't think you can, I can't remember if you could do this off the top of my head; tell us what exactly you are trying to do instead of being so general.
Reply With Quote  
Join Date: Sep 2004
Posts: 10
Reputation: laxy_m is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
laxy_m laxy_m is offline Offline
Newbie Poster

Re: How can I send variables from a PHP script to another URL using POST without.........

  #3  
Oct 6th, 2004
ok thanks i will try it.

Regards
Laxy
Last edited by cscgal : Apr 6th, 2006 at 9:15 pm.
Reply With Quote  
Join Date: Apr 2006
Posts: 2
Reputation: vijiruba is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
vijiruba vijiruba is offline Offline
Newbie Poster

Re: How can I send variables from a PHP script to another URL using POST without.....

  #4  
Apr 4th, 2006
Have u got solution for this.
Reply With Quote  
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,165
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Rep Power: 7
Solved Threads: 59
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: How can I send variables from a PHP script to another URL using POST without.....

  #5  
Apr 4th, 2006
You can do it with javascript, here a good article with the basics:
http://www.w3schools.com/dom/dom_http.asp

Basically you can create an HTTP request from within your page and get back and process a responce.

I guess this could be possible in PHP also. I have a look into it.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote  
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,165
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Rep Power: 7
Solved Threads: 59
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: How can I send variables from a PHP script to another URL using POST without.....

  #6  
Apr 4th, 2006
Here you go check this out:

http://uk.php.net/curl
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote  
Join Date: Jun 2006
Posts: 6
Reputation: manishMCAIT is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
manishMCAIT manishMCAIT is offline Offline
Newbie Poster

Re: How can I send variables from a PHP script to another URL using POST without.....

  #7  
Jul 10th, 2006
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 (http://curl.haxx.se). 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.

To use cURL you need to recompile PHP or check with your ISP to see if they support it (http://www.php4hosting.com does)
Reply With Quote  
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: How can I send variables from a PHP script to another URL using POST without.....

  #8  
Jul 10th, 2006
If you are posting within your own server, you may not need to connect to the host as shown by manishMCAIT.
Ecommerce-Web-Store.com Building Your e-Business.
Reply With Quote  
Join Date: Nov 2006
Posts: 2
Reputation: Bryan McPherson is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Bryan McPherson Bryan McPherson is offline Offline
Newbie Poster

Help Re: How can I send variables from a PHP script to another URL using POST without.....

  #9  
Nov 30th, 2006
Hi Lexy M, I have checked this site, they are doing some cool work on PHP also there article collection is strong...check it on www.webdesigningcompany.net/articles.php
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 4:49 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC