JS Confirm with PHP

admin

Administrator
Staff member
Hi there.
I am using a database and php.
When I delete a record there must come a confirmation box with YEs and NO. On yes he goes thru the rest of the PHP code to delete. Choosing NO wil go one page back. This is what I have:



if ($action == "delete") {


print ("<script>
function ask() {
var agree=confirm('Are u sure?');
if (agree) {
alert('OK you were sure');
document.write('Deleted');
}
else {
alert('Record deleted');
history.go(-1);
}
}
ask();
</script> ");

ask();


The php code to delete...


When I push "cancel" it works well. If I choose OK, I get a php error saying "Undefined function". If I delete that last line Ask(); from the pgp source, then the Cancel Button also doesn;t work anymore. Can somebody help me?
 
Back
Top