Hi everyone,
this is the code in slim php:
$app->post('/checkSignIn', function() use ($app) {
$params = $app->request->post()['body'] ;
if(!empty($params))
{
$jsonRequest = json_decode($params);
//echo $jsonRequest->email;
$delikatesDbConnect = new DelikatesDbConnect ('localhost', 'gontar_delikates', 'DgDgDg11', 'gontar_delikates');
$id = $delikatesDbConnect->findUserIdByMail($jsonRequest->email);
//echo $id;
if ($id>0) // if $id exists fetch hashed password and email_verfied values
{
$hashed_password = $delikatesDbConnect->findPasswordById($id);
$email_verified = $delikatesDbConnect->findEmailVerifiedById($id);
if (password_verify($jsonRequest->password,$hashed_password) and ($email_verified))
{
$arr = $delikatesDbConnect->json_user_details($id);
$jsonResponse = json_encode($arr);
$response = new HttpResponse($jsonResponse,202);
return $response;
}
else
{
return '';
}
}
else
{
return '';
}
}
else
{
return '';
}
})->name('register');
this is the request code in typscript ng2:
sendUserAndPass(userDetails:JSON)
{
const body = JSON.stringify(userDetails);
console.log(body);
const headers = new Headers();
headers.append('Content-Type','application/json');
this.http.post("http://www.delikates.co.il/backend/checkSignIn", body, {headers: headers})
.subscribe((data:Response)=>console.log(data));
}
,爲什麼我會在Chrome控制檯ERR消息那樣: 選項http://www.delikates.co.il/backend/checkSignIn網:: ERR_EMPTY_RESPONSE角2應用程序的響應是網:: ERR_EMPTY_RESPONSE
例外:響應,狀態:0的網址:空
未捕獲的響應{_body:ProgressEvent,狀態:0,OK:假,狀態文本: 「」,標題:頭...}
當我通過簡單的HTML表單檢查,PHP程序進入重要的if語句:如果(password_verify($ jsonRequest->密碼,$ hashed_password)和($ email_verified)){ $ arr = $ delikatesDbConnect-> json_user_details($ id); $ jsonResponse = json_encode($ arr); $ response = new HttpResponse($ jsonResponse,202); 返回$ response; } –