Answer the question
In order to leave comments, you need to log in
How to write data from input to MySQL?
(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();
Answer the question
In order to leave comments, you need to log in
The comment to the dude above is just out loud)))
mysql_query --> mysqli_query
mysql_close --> mysqli_close
and everything will be a bundle.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question