When I use the following code, i redirects to my own domain with https (I get 404 error because I dont use SSL on my domain)
EDIT: If my URL where the curl script is http://example.com/index.php it redirecting to https://example.com.com/index.php
It's not the same problem as other questions. I get error 404. I dont get the error with where I need to use curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$url = 'https://www.homepage.com';
$fields = array('username'=>'abc', 'password'=>'1234', 'loginbutton'=> 'Login');
$postvars='';
$sep='';
foreach($fields as $key=>$value)
{
$postvars.= $sep.urlencode($key).'='.urlencode($value);
$sep='&';
}
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$postvars);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch);
curl_close($ch);
echo $result;