code Curl:boucle connexion à distance Erro
$username = $_POST["email"];
$password = $_POST["password"];
$headers= array('Accept: application/json','Content-Type: application/json');
$url="http://localhost/hrm_1.7/source/admin/login";
$data = array('email'=>$username,'password'=>$password);
$postinfo = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$postinfo);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_exec($ch);
curl_setopt($ch, CURLOPT_URL,"http://localhost/hrm_1.7/source/admin/dashboard");
$html = curl_exec($ch);
curl_close($ch);
Code AJAX:
$.ajax({
type: "POST",
url: " http://localhost/hrm_1.7/source/admin/login ",
dataType: 'json',
data: $('#login-form').serialize()
}).done(function(response) {
if(response.status == "success")
{
window.location.href= "http://localhost/hrm_1.7/source/admin/dashboard";
}
});
le code AJAX fonctionne bien et sur le succès qu'il logins et rediriger vers dashboard.But que je veux faire en utilisant curl. Quel est le problème avec mon code curl?
Y at-il $ _POST méthodes de type consignataire dans admin/tableau de bord? –
@AniruddhaChakraborty que je ne sais pas mon code ajax fonctionne et j'ai besoin de savoir ce qui ne va pas avec mon code curl. – afsarkhan10182