form still deleting mysql result after canceling 'confirm'
Posted: Sat May 09, 2009 7:42 am
Hi,
I have tried to add a message when the submit button is clicked when deleting a result from mysql.
The message appears but if I click cancel the form still deletes the entry anyway!! This must be something wrong on the php side of the script but I just cant put my finger on it...
Heres my code:
I have tried to add a message when the submit button is clicked when deleting a result from mysql.
The message appears but if I click cancel the form still deletes the entry anyway!! This must be something wrong on the php side of the script but I just cant put my finger on it...
Heres my code:
Code: Select all
<?php
if($_POST['Delete']){
$query = "DELETE FROM games WHERE id = '$id'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error()); }{ ?>
<form method="post" action="">
<input type="image" src="images/btn_delete.jpg" name="Delete" value="Delete" onClick="if(confirm('Are you sure you want to delete this game?')) document.test_form.submit();"></form>
<?php } ?>