file_get_contents() with POST method

gesf

Active member
Hey mlotfi63,

You can use PHP cURL functions for that.
Example:
Code:
<?php

$url = "http://somehost.ext/datafile.php";

// v1, v2 - whatever the values come from ...
$post = "param1=" . $v1 . "&param2=" . $v2;

$session = curl_init($url);
curl_setopt($session, CURLOPT_URL, $url);
curl_setopt($session, CURLOPT_HEADER, 0);
curl_setopt($session, CURLOPT_POST, 1);
curl_setopt($session, CURLOPT_POSTFIELDS, $post);
curl_setopt($session, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($session, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($session);
curl_close($session);
return $data;

?>
Hope it helps ;)
 
Back
Top