I've some problem in inserting data, but before inserting data into table i want to use confirmation using JavaScript to ask user about inserting data..
this the script :
<?php
//file name : [b]function .php[/b]
//function to insert data into the table
function insertData($sql)
{
//confirm the user
?>
<script language=JavaScript>
<!--
if(confirm('Are you sure want to add new user ?') == true)
{
<?php
$query = mysql_query($sql) or die (mysql_error());
?>
alert('Input Data Success..!!');
}
else
{
alert('Input Data Cancel by user..!!');
}
//-->
</script>
<?php
}
?>
<?php
[b]file name : insert.php[/b]
include ('function.php');
//i cut the source, cos i think the problem start in here... =)
$sql = "INSERT INTO user(id_user,name,pass) VALUES('$increment','$v_name','$v_pass2')";
insertData($sql);
?>
problem :
when browser display confirmation dialog contain and i choose cancel, it should be don't add anything in to the table, but fact is it add data into the table...
thanx 4 ur reply...
