I had a problem.I wanna do a query only when i click a button but without click it did the query the code is:
<html>
<head>
   <title>prova del metodo post tramite javascript</title>
   <script>
   function scriviSQL(){
    document.write("<?php   
    $con = mysql_connect('localhost','root');
    if (!$con)
    {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db('provadidb', $con);
    $sql = 'INSERT INTO provatab (cognome,nome) VALUES("provdicognome","provadinome");';    
    mysql_query($sql,$con);
    mysql_close($con);  
    ?>");
   }
  </script>
    <button id="conferma" onClick="scriviSQL();">Continua</button> 
i tryed to put it in body or head i had the same problem, i tryed to create a function with php too but nothing... sorry for my bad english..
 
     
    