I'm working on an android app, a java app, and i called for a response from a php file uploaded on my host, and my response is ' []', i checked the php code and i dont know what the problem is, i saw some posts it's an encode problem about which i dont know nothing, can you help me please , here's my php code.
<?php
require_once '../includes/DbConnect.php';
$response =array();
if($_POST['username'] && $_POST['password']){
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT * FROM users WHERE username=?";
$stmt = mysqli_stmt_init($con);
mysqli_stmt_bind_param($stmt,"s",$username);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if($user = mysqli_fetch_assoc($result))
{
$passwordCheck = password_verify($password,$user['password']);
if($passwordCheck == false){
$response['error'] = true;
$response['message'] = "Invalid username or password";
}
else if($passwordCheck == true) {
$response['error'] = false;
$response['id'] = $user['idUsers'];
$response['email'] = $user['email'];
$response['username'] = $user['username'];
$response['country']= $user['country'];
$response['firstname']= $user['firstname'];
$response['lastname']= $user['lastname'];
$response['points']= $user['points'];
}
}
}
echo json_encode($response);
?>