note 93351 added to function.curl-setopt
| From: | Tyranoweb at osu1 dot php dot net | Date: | Fri, 04 Sep 2009 21:42:41 +0000 |
| Subject: | note 93351 added to function.curl-setopt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-160226@lists.php.net to get a copy of this message | ||
There is a function to send POST data in page with five parameters :
$post must be an array
$page is the page where POST datas will be send.
$n must be true to continue if they are php redirection (Location: )
$session must be define true if you want to use cookies
$referer must be a link to get a wrong referer or only to have a referer.
function curl_data_post($post, $page, $n, $session, $referer)
{
if(!is_array($post))
{
return false;
}
$DATA_POST = curl_init();
curl_setopt($DATA_POST, CURLOPT_RETURNTRANSFER, true);
curl_setopt($DATA_POST, CURLOPT_URL, $page);
curl_setopt($DATA_POST, CURLOPT_POST, true);
if($n)
{
curl_setopt($DATA_POST, CURLOPT_FOLLOWLOCATION, true);
}
if($session)
{
curl_setopt($DATA_POST, CURLOPT_COOKIEFILE, 'cookiefile.txt');
curl_setopt($DATA_POST, CURLOPT_COOKIEJAR, 'cookiefile.txt');
}
if($referer)
{
curl_setopt($DATA_POST, CURLOPT_REFERER, $referer);
}
curl_setopt($DATA_POST, CURLOPT_POSTFIELDS, $post);
$data = curl_exec($DATA_POST);
if($data == false)
{
echo'Warning : ' . curl_error($DATA_POST);
curl_close($DATA_POST);
return false;
}
else
{
curl_close($DATA_POST);
return $data;
}
}
----
Server IP: 89.31.146.176
Probable Submitter: 82.241.138.66
----
Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php
Edit -- https://master.php.net/note/edit/93351
Del: integrated -- https://master.php.net/note/delete/93351/integrated
Del: useless -- https://master.php.net/note/delete/93351/useless
Del: bad code -- https://master.php.net/note/delete/93351/bad+code
Del: spam -- https://master.php.net/note/delete/93351/spam
Del: non-english -- https://master.php.net/note/delete/93351/non-english
Del: in docs -- https://master.php.net/note/delete/93351/in+docs
Del: other reasons-- https://master.php.net/note/delete/93351
Reject -- https://master.php.net/note/reject/93351
Search -- https://master.php.net/manage/user-notes.php