"how to sent request in php" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "how to sent request in php" answered properly. Developers are finding an appropriate answer about how to sent request in php related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like how to sent request in php. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on how to sent request in php.
how to sent request in php
$url = 'http://server.com/path';
$data = array('key1' => 'value1', 'key2' => 'value2');
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }
var_dump($result);
Source: stackoverflow.com
how to sent request in php
<?php
//The url you wish to send the POST request to
$url = $file_name;
//The data you want to send via POST
$fields = [
'__VIEWSTATE ' => $state,
'__EVENTVALIDATION' => $valid,
'btnSubmit' => 'Submit'
];
//url-ify the data for the POST
$fields_string = http_build_query($fields);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//So that curl_exec returns the contents of the cURL; rather than echoing it
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
//execute post
$result = curl_exec($ch);
echo $result;
?>
Source: stackoverflow.com
All those coders who are working on the Whatever based application and are stuck on how to sent request in php can get a collection of related answers to their query. Programmers need to enter their query on how to sent request in php related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about how to sent request in php for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of how to sent request in php while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "how to sent request in php". Visit this developer's friendly online web community, CodeProZone, and get your queries like how to sent request in php resolved professionally and stay updated to the latest Whatever updates.