-1
I have a music download system with a download button and I would like when clicking the button, it insert a line in the database, without leaving the page.
Currently what I did is it open a new page that makes the Insert:
For each song have this code in the table row:
<form method="post" action="inseremusica.php">
<input type="text" name="id">
<button type="submit">
</form>
php.
<?php
$conn = new mysqli($servername, $username, $password, $dbname);
$sql = "INSERT INTO euk_lista_downloads (idmusica, data)
VALUES ($_POST['id'], date('d/m/Y H:i:s', time()))";
$conn->query($sql);
$conn->close();
?>
Make a call
Ajax
: https://answall.com/questions/190816/como-executar-uma-fun%C3%A7%C3%A3o-php-no-ajax– Ricardo Pontual