I created an onclick javascript function and the idea is to send values in the database table in every click of the button/a href but it seems that in every time I reload/open the page in the web it sends and runs every single function/query automatically.
This the function in my html file
//audit trail
function auditPrint(){
<?php
mysqli_query($conn,"insert into `audittrail` (user,activity) values ('employee','printed receipt')");
?>
}
function auditCancel(){
<?php
mysqli_query($conn,"insert into `audittrail` (user,activity) values ('employee','canceled transaction')");
?>
}
function auditLogout(){
<?php
mysqli_query($conn,"insert into `audittrail` (user,activity) values ('employee','logged out')");
?>
}
It works fine but I would like it to send only if I click the button. Is there a way I can fix it?