这是我的php代码,我没有收到任何json响应。
if ($_SERVER['REQUEST_METHOD']=='POST') {
$email = isset($_POST['email']) ? $_POST['email'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
require_once 'connect.php';
$sql = "SELECT * FROM users_table WHERE email='$email'";
$response = mysqli_query($conn, $sql);
$result = array();
$result['login'] = array();
if ( mysqli_num_rows($response) === 1 ) {
$row = mysqli_fetch_assoc($response);
if ( password_verify($password, $row['password']) ) {
$index['name'] = $row['name'];
$index['email'] = $row['email'];
$index['id'] = $row['id'];
array_push($result['login'], $index);
$result['success'] = "1";
$result['message'] = "success";
echo json_encode($result);
mysqli_close($conn);
} else {
$result['success'] = "0";
$result['message'] = "error";
echo json_encode($result);
mysqli_close($conn);
}
}
}
?>
这是我的PHP代码,可能是什么错误?请帮我。我是堆栈溢出的新手,所以也请忽略我的错误。谢谢。