'php curl login not work, code tested with other site

I have a problem with curl remote login, i don't know what the issue , tried the code with other site working but with my customer website not working

function get_cURL() {

        $url = "https://qualitycarrentalltd.com/admin/login.php";
        $ch = curl_init($url);
        $credentials = "user=myusername&pass=mypassword&Submit=Login";
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $credentials);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

        curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8','Accept-Language:     en-us,en;q=0.5','Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7','Keep-Alive: 115','Connection: keep-alive'));

        curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie-name.txt');
        curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie-name.txt');

        $result = curl_exec($ch);
        curl_close($ch);

        return $result;
}

var_dump(get_cURL());

another code

$url = 'https://qualitycarrentalltd.com/admin/login.php';
$data = array('user' => 'myusername', 'pass' => 'mypassword', 'Submit' => 'Login');

// use key 'http' even if you send the request to https://...
$options = array('http' => array(
    'method'  => 'POST',
    'content' => http_build_query($data)
)
);

$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);

print_r($result);

Why login not working? it take days from me without found solution, Can someone help with fix Please



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source