Не могу отправить данные из php в базу данных mysql. Данные получаю через js, потом через Ajax передаю их в php, а уже от туда хочу отправить в mysql, однако ничего не получается. Вот что пишет сам браузер:

И сам код: JS код (checkTests.js):
// Отправка данных на сервер
$(document).on('click', '.checkBtn', function(){
let userPoints = getCookie('points'),
allPoints = getCookie('allPoints');
$.ajax({
url: '../js/updateDB.php',
type: 'POST',
dataType: 'json',
data: {
userPoints: userPoints,
allPoints: allPoints,
}, success: function(){
console.log('Данные отправлены!')
}
})
})
php код (updateDB.php):
<?php
$arr['userPoints'] = $_POST['userPoints'];
$arr['allPoints'] = $_POST['allPoints'];
echo json_encode($arr);
$userPoints = $arr['userPoints'];
$allPoints = $arr['allPoints'];
$login = filter_var(trim($_POST['login']), FILTER_SANITIZE_STRING);
$password = filter_var(trim($_POST['password']), FILTER_SANITIZE_STRING);
$password = md5($password.'afm430fx0a');
include 'connect.php';
$result = $mysql->query("SELECT * FROM `users` WHERE `login` = '$login' AND `password` = '$password'");
$mysql = $result->fetch_assoc();
$mysql->query("INSERT INTO users (points) VALUES ('$userPoints')");
// $mysql->query("INSERT INTO `goals` (`allPoints`) VALUES ('$userPoints')");
$mysql->close();
header("Location: /");
?>
$arr = [];? Кхм.. По видимому нет. Смотрите на вкладкеnetworkчто вернулось, если php ошибки не выключены, вы поймете в чем проблема. – Oliver Patterson Aug 20 '22 at 12:58