Here's a curl script that sends data from a form. I'm new to using Curl, and want to understand it better. Am I sending data, with curl, in a POST method? Or can I vary between GET and POST?
I've looked at the manual: http://us.php.net/curl but I'm not quite seeing a direct answer to it.
Any clarification would be appreciated!
here's what I have made:
[code=php]$data =
'&e='.urlencode($_POST['email']).
'&f='.urlencode($_POST['firstName']).
'&l='.urlencode($_POST['lastName']).
'&IP='.urlencode($_SERVER['REMOTE_ADDR']).
'&a1='.urlencode($_POST['address']).
'&c='.urlencode($_POST['city']).
'&sp='.urlencode($_POST['state']).
'&pc='.urlencode($_POST['zip']).
'&od='.urlencode(date('Y-m-d H:i:s')).
'&pn='.urlencode($_POST['phone']);
$ch = curl_init('http://somewebsite.asp');
//set URL and other appropriate options
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_TIMEOUT, '1800');
//Execute the request.
$data_response = curl_exec($ch);
$succeeded = curl_errno($ch) == 0 ? true : false;
echo $data.'<br>';
echo $data_response;[/code]