someone can help me for this problem please ? I don't understand why it happened.
Javascript code :
login = () => {
const {username,userPassword} = this.state;
fetch('http://192.168.43.171:8080/SERVEURWEB_SMARTCAGE/php/connexion-verif_massi.php',{
method:'post',
header:{
'Accept': 'application/json',
'Content-type': 'application/json'
},
body:JSON.stringify({
nom: username,
password: userPassword,
})
})
.then((Response) => Response.json())
.then((ResponseJson)=>{
if(ResponseJson == "entraineur"){
this.props.navigation.navigate('EntraineurInterface');
}
else if(ResponseJson == "joueur"){
this.props.navigation.navigate('JoueurInterface');
}
else{
alert("Je rentre pas dans la boucle");
console.log(ResponseJson);
}
})
.catch((error)=>{
console.error(error);
})
}
PHP CODE
<?php
// Importing DBConfig.php file.
include 'config.php';
$json = file_get_contents('php://input');
$obj = json_decode($json,true);
// Populate User nom from JSON $obj array and store into $nom.
$nom = $obj['nom'];
// Populate Password from JSON $obj array and store into $password.
$password = hash('sha256',$obj['password']);
//Connexion to database and verif the data send by the application
if ($obj['nom']!=""){
$result = $bdd->query("SELECT * FROM utilisateurs WHERE nom = '$nom' and password = '$password'");
if ($result->rowCount()==0){
echo json_encode('Mauvaises Informations');
}
else{
$userinfo = $result->fetch();
if($userinfo['type'] == 'entraineur'){
echo json_encode('entraineur');
}
else($userinfo['type'] == 'joueur'){
echo json_encode('joueur');
}
}
}
else{
echo json_encode('reessayer');
}
?>
error :
JSON Parse error: Unrecognized token '<' at node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne at node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0 at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:123:14 in _callTimer at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:177:14 in _callImmediatesPass at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:437:30 in callImmediates at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:388:6 in __callImmediates at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:132:6 in __guard$argument_0 at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:365:10 in __guard at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:131:4 in flushedQueue
I hope someone can help me with this problem.