This Tutorial Has Been Viewed 9,968 Times.
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
You will also be interested in ,
- Check whether a url exist or not using php and curl
- Get the content of a webpage in to variable using curl php
- Store Data In Remote DataBase Using cUrl or Execute a HTTP POST Using PHP CURL
- Login to yahoo using cUrl in php
- Enabling curl on XAMPP for Windows
- How to get the IP address of the visitor with PHP?
- Adding Handlers Directly In httpd.conf Of Apache
- Read text file reverse using php
- Simple auto suggest script using ajax php css and tags from wordpress
- Display Tags in wordpress