I try to submit login form with phpcommand: curl, but it doesn’t work.
The fields form are two: email and psw.
The problem is that if I use urlencode to field email it return the error: “incorrect format email!”, while if I not use the urlencode there aren’t response.
This is the code without urlencode:
$url = 'myurl';
$fields = array(
'login_email'=> 'myemail@gmail.com',
'login_passwd'=> 'mypsw',
'remember_me' => '1'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Return page in string
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields);
$page = curl_exec($ch);
echo $page;
//close connection
curl_close($ch);
Are you sure there’s no response? Many login systems simply do a redirect to some other page if the login is successful. Try adding
which’d let CURL obey the redirect and fetch whatever page the server’s sending you off to.
Alternatively, you can use the
CURLOPT_HEADERoption to include the HTTP headers in the response returned into your$pagevalue and see what’s going on there.