Hi there~ I am kinda coding a verrry simple information system which uses Javascript.
I am not familiar with JS and I only know the basics, but maybe what I'll ask is a veeery simple one but oh well, should I be asking if I found a solution after searching in google? No. So I am here again in DW since I have a LOT of good impression and like 90% of the posts I made were solved. :D So here goes:
delete.php
<?php
$con=mysql_connect("localhost","root");
mysql_select_db("dbfirest",$con);
$s=$_POST['id'];
?>
<script type="text/javascript">
var answer = confirm ("Delete Item?")
if (answer)
<?php $sql="delete from tblfireincidents where fire_id='".$s."'";
mysql_query($sql);?>
alert ("Incident Deleted")
else
alert ("Delete Aborted")
self.location="fire_index.php"
</script>
So as you can see, here is the code for the delete button from a form which deletes a certain record ($s).. The thing is, I added a javascript prompt that asks the user if he is sure.. When clicked Yes, the record will be deleted.. If clicked Cancel.. It will not delete the record.. But that situation SHOULD be happening right?
But no.
That code, (up up there) if clicked Cancel will ALSO delete the record which shouldn't be happening at all. Uggh. Can you help me with this, guys?