How can I do to call a PHP function within a JavaScript function?
Below, follow my code:
<script language="Javascript">
function cadastrarpapel() {
<?php $sql = msyqli_query($conn, "INSERT INTO cadastropapel (tipopapel, valorpapel) VALUES ('$tipopapel','$valorpapel') ");
echo "Cadastrado com sucesso!";
?>
}
</script>
<form method="POST" action="#">
<input type="text" name="tipopapel" placeholder="Tipo do Papel">
<input type="text" name="valorpapel" placeholder="Valor do Papel">
<input type="submit" value="Cadastrar Papel" onclick="cadastrarpapel()">
</form>