I have a function in PHP (I read that it was recommended to make modifications in the database in PHP and not in JS)
function insertTable()
{
$name = 'nome';
$categoria = 'categoria';
$download = 1000;
$upload = 1000;
$magnet = 'magnet';
mysqli_query($connect, "INSERT INTO torrents('Nome', 'Categoria', 'DownloadQuantity', 'UploadQuantity', 'Magnet') VALUES ('".$name."', '".$categoria."', ".$download.", ".$upload.", '".$magnet."')");
}
And in my function in JS (it is in action
of a button) I want to call the function insertTable()
.
I read that PHP runs on the server and JS runs in the browser, the only way I found it was when the function in PHP is in a separate file, so using AJAX, but I want to do this with both functions in the same file.