I'm actually coding a little authentification service in angular for front side and php for server side.
When I post identification to the server for check identification the server responds with a boolean, true if ID are correct or false if isn't.
When I try my function with POSTMAN the response is good (true for good ID , false for wrong ID) BUT when I use it with angular with EXACTLY the same argument the server always response FALSE
Here is the code :
Server side :
else if($action == 'Connection'){
try{
$project = $_POST['project'];
$username = $_POST['username'];
$password = $_POST['password'];
$stmt = $bdd->prepare("SELECT * FROM Projects WHERE name = :name AND admin_user = :username AND admin_pwd = :password");
$stmt->bindParam(":name", $project);
$stmt->bindParam(":username", $username);
$stmt->bindParam(":password", $password);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
if(count($result) === 0) {$response->credentialsOk = false;}
else {$response->credentialsOk = true;}
echo(json_encode($response));
}catch(Exception $e){
die('Erreur : '.$e->getMessage());
}
}
Client side :
$rootScope.Connect = () => { // === $rootScope.Connect = function() { ... }
//Ask to the server if credentials is correct
$http.post(Global.url_api+'action=Connection',{username : $scope.username , password : $scope.pwd, project : $rootScope.project })
.then((response) => {
console.log(response);
})
}
Result
Yes I used exactly the same ID
Please guide me on the good way
Thanks in advance