I am trying to login to a system using cURL. But I can not log in, I think the problem is redirection.
I have a website (mysite.com) that has a form. this form calls the submit.php page. On this page I have the following code
<?php
//pega os inputs através do furmulário vindo do método POST.
$login = $_POST['login'];
$senha = $_POST['senha'];
$ch = curl_init();
$data['login'] = $login;
$data['senha'] = $senha;
$data['submit'] = 'true';
$dataall = http_build_query($data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_URL, 'http://sistemaweb/login.php');
curl_setopt ($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataall);
curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, 'http://sistemaweb/dashboard.php');
$a = curl_exec($ch);
echo $a;
curl_close($ch);
?>
The problem occurs when it calls the page. it play to the url myite.com / dashboard.php instead of systemweb / dashboard.php
The url does not leave my domain. I have tried in many ways but I have not been successful. even tried a header location but it seems that he realizes the session.
Is there any more missing parameters in the CURL process?