I have a JavaScript confirm box and i have some MySQL insert query code to be executed at some condition. This is how my code look like:
<?php
$id = $_POST['id'];
$name= $_POST['name'];
$query = mysql_query("select * from table where id='$id'");
$count    =   mysql_num_rows($query );
if($count!=0)
{
?>
   <script type="text/javascript">  
        if (confirm("This seems to be Duplicate. Do you want to continue ?") == true)
        {
            //Execute/Insert into table as how it is given below
        }
        else
        {
            //Dont execute/insert into table but close the window
        }
     </script>
<?php
}
else
{
    $queryinsert = mysql_query("INSERT INTO table(id,name) VALUES('$id','$name')");
}
?>
 
     
     
     
    