[thelist] Submitting Request.ServerVariables("REQUEST_METHOD") in the URL

Rodrigo Fonseca lists at vega.eti.br
Sat Oct 4 12:45:39 CDT 2003


Alexis Antonakis wrote:
> Hi Rodrigo,
> 
> Thanks for the Info. I will look into this further.
> 
> Regards
> Alexis

A quick example to help you out:

$ch = curl_init(); // init
// Next line is the page that will get the form post
curl_setopt($ch, CURLOPT_URL, "http://www.domain_here.com");
// do not print any errors
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
// if the page requires a valid referer use this:
curl_setopt($ch, CURLOPT_REFERER, "http://www.referer_page_here");
// follow the destination (URL) location
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
// timeout - in seconds
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
// return the transfer instead of printing it out
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
// perform a regular HTTP post
curl_setopt($ch, CURLOPT_POST, 1);
// the fields you want to post (build them as a normal query string)
curl_setopt($ch, CURLOPT_POSTFIELDS,"var1=value&var2=value2&var3=test");
// exec the transfer or go to an error page
$result = curl_exec ($ch) or die(header("Location: ./error.php"));
// close the connection
curl_close ($ch);

The $result variable will then get the content of the transfer, it can
be a full response web page or just an array with values or a thank you
message, depending ou how the "http://www.domain_here.com" page is
written. Try printing the $result variable or:
print '<pre>';
print_r($results);
print '</pre>';

This is the most common example of use, it should suit most
requirements.
Hope that helps you to start playing with it.
There are plent of other options to work with, take a look at the
documentation and user examples.

Best regards,

	Rodrigo Fonseca.



More information about the thelist mailing list