confirm box in javascript while inserting record
<p>i am inserting an record in database, while inserting i have to check if that value is already in the db. If it found then there will be a confirm box showing that 'Record is already in database. Do you want to add?'.<br>
while doing this, if the record found then i have given a confirm message in javascript and in that i wrote the insert query and then complete the script. It works, but if the user click on the Cancel button, then also record is inserted. Why this happen?
I use this code - </p>

<pre><code>&lt;script type="text/javascript"&gt;
    if(confirm('Record already exist. Do you want to add?')) {  &lt;?
        $insert = mysql_query("insert into user ----------");
    ?&gt; }
&lt;/script&gt;
</code></pre>

<p>thanks.</p>
