facebook twitter youtube
in cUrl - 02 May, 2009, This Tutorial Has Been Viewed 13,690 Times.
by admin - no comments
Post Data To Another Website Using cURL In PHP
VN:F [1.9.22_1171]
Rating: 8.0/10 (7 votes cast)

Hello guys, Glad to say that this is my 100th Post.The below code will help you how to post data from your webite to another website using cUrl in PHP

<?php
$urltopost = "http://mywebsite.com/post.php";
$datatopost = array ("firstname" => "James",
"lastname" => "Anderson","email" => "admin@mistonline.in",);
 $ch = curl_init ($urltopost);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$returndata = curl_exec ($ch);
?>

$urltopost
The url where you want to post your data to

$datatopost
The post data as an associative array. The keys are the post variables

$ch = curl_init ($urltopost);
Initializes cURL

curl_setopt ($ch, CURLOPT_POST, true);
Tells cURL that we want to send post data

curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost);
Tells cURL what are post data is

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
Tells cURL to return the output of the post

$returndata = curl_exec ($ch);
Executes the cURL and saves theoutput in $returndata

Thanks a lot http://coderscult.com

VN:F [1.9.22_1171]
Rating: 8.0/10 (7 votes cast)
Post Data To Another Website Using cURL In PHP, 8.0 out of 10 based on 7 ratings

Incoming search terms:




coded by nessus

Leave a Reply

Close
Please support the site
By clicking any of these buttons you help our site to get better