I have a website using php and mysql. It's used to modify database entries(add,modify,delete). But i have a problem: in html-form there's delete-button,when clicked it should do confirm using javascript.works fine but it doesn't matter if you click ok or cancel,it's deleted anyway.
Form code:
<input type="button" name="delete" value="delete" onClick="prompt()">
javascript code:
function prompt() {
var agree=confirm("Do you really want to delete this entry");
if (agree)
return true;
else
history.go(-1);
}
php code:
elseif ($delete) {
if ($agree) {
$db = mysql_connect("localhost", "user", "pass");
mysql_select_db("hankinnat",$db);
$sql = "delete from testaus where id=$id";
$result = mysql_query($sql);
}
}
Propably php doesn't understand javascript variables. Any suggestion how to do this kind of confirming?? It doesn't have to be with javascript.All ideas would be nice.