(function (){
var sendData = function () {
var data = new FormData(firstForm);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
console.log(xhr.response);
}
};
xhr.open('POST', 'data.php');
xhr.send(data);
};
window.backend = {
send: sendData
}
})();
<?php
$db_host = "192.168.1.4";
$db_user = "n1cro";
$db_password = "XRT6IPLkeK5DyYzc";
$db_name = "invitation";
$link = mysqli_connect($db_host, $db_user, $db_password, $db_name)
or die("Ошибка " . mysqli_error($link));
mysql_query("INSERT INTO 'users' ('firstname', 'lastname')
VALUES (' ".$_POST['firstname']." ',' ".$_POST['lastname']." ')");
mysql_close();
Вот какие ошибки в консоле браузера:
Warning: mysql_query(): in
D:\OSPanel\domains\invitation\build\data.php on line
20Warning: mysql_query(): A link to the server could not be established in
D:\OSPanel\domains\invitation\build\data.php on line
20Warning: mysql_close(): no MySQL-Link resource supplied in
D:\OSPanel\domains\invitation\build\data.php on line
22