In the begging, on the console appears:
Uncaught SyntaxError: Unexpected token '<'" .
Can't i call this function or other functions? I would like to do somethings like insert on my SQL database but that minimal code there is struggling too and I don't know why (PHP funcion add).
<button type="button" onclick="phpadd()" onclick="showSwal('auto-close')" id="add" class="btn btn-lg clear font-weight-light" style="background-color: #fccf03;color: white;">Add to Log</button>
<?php
function add($a,$b){
session_start();
include('conexao.php');
if (!$_SESSION['usuario']) {
header('Location: indexM.php');
exit();
}
return 1;
}
?>
<script>
function phpadd() {
var padd = <?php echo add(1, 2); ?>; // call function to insert value
alert(padd);
}
</script>
– Muax Mar 01 '21 at 21:16