I need a script to send some variables as post. Basically I need to replicate a form that sends values with method post. No need for login, cookies or something else. I will appreciate any help.
Hope it's what you need function format_post($data) { $result = ""; foreach ($data as $k => $v) { $result .= "&".urlencode($k)."=".urlencode($v); } return substr($result, 1); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); $params = array( "a" => $a, "b" => $b, ); curl_setopt($ch, CURLOPT_POSTFIELDS, format_post($params)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); $result = curl_exec($ch); curl_close($ch); PHP: