PHP Post Data To Another Website
PHP Post Data To Another Website
PHP Post Data To Another Website Using cURL
We are using PHP with the help of CURL to post data to another website. In order to do this you should be knowing the URL to which you should post the request, The fields used in the POST page like here for example I have used fields like “firstname”, “lastname” and “email”.
Once the data is posted. We can even display the return data using the curl_exec function. Please find the code below and I have tried to explain all the variables used here.
<?php $urltopost = "http://mywebsite.com/post.php"; $datatopost = array ("firstname" => "James", "lastname" => "Anderson","email" => "[email protected]",); $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!!! 🙂
PHP Post Data To Another Website,Incoming search terms:
- yhs-default (10)
- php curl post data (1)
- php how to send post data to another website (1)
- php post data to another site (1)
- php post to other site (1)
- php post to other website (1)
- php post to webpage with curl (1)
- php script display information from another URL on my website (1)
- php script to diaplay other website (1)
- php script to post an ecommerce sites post to server and display in html page (1)
- php send data to another php (1)
- php send data to another website (1)
- php send post data to another site (1)
- Post and get to another site php (1)
- post other website php (1)
- send post to another site (1)
- use data from other website using curl and php (1)
- php curl get data from website (1)
- how to send information to a site (1)
- how to send data to another website in php (1)
- curl exetute post as another ip (1)
- curl for login another php (1)
- curl post array returndata (1)
- fetch content from other websites (1)
- fetch data from another website in php (1)
- fetch data from other website in php (1)
- get data another web curl (1)
- how to display another website in my php (1)
- how to fetch data from other site in php (1)
- how to fetch datafrom other site in php (1)
- How to get data from another site by php web (1)
- how to get on another site via php (1)
- how to login and get data from website in php (1)
- how to post data to another website (1)
- how to post data using curl in php (1)
- how to post web to onether web (1)
- $urltopost (1)
Can you explain what we will do if we dont know the table structure of remote database ??
Hi how to fetch database table using curl, can you help me
Hello Siva,
You can load the web page into a DOM Object and parse it to get specific data.