PHP curl login website

Job ID: 31725273

Budget: €8 – €30 EUR

I need help with a remote login on a website. It's just a simple form with username and password, and I try to login with curl like this:
<?php
$data = array(
"user" => "***",
"pass" => "***"
);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$result = curl_exec($ch);
curl_close($ch);
echo $result;
?>

But it's not working. I need quick assistance.
Related categories: PHP cURL