Call function in Form [duplicate]

0

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>
    
asked by anonymous 05.08.2018 / 04:36

0 answers