图像的确认删除消息框


confirmation delete message box for an image?

该场景是当我单击tour_manage.php中记录旁边的X图像时,这将删除由另一个名为delete_tour.php的php页面执行的记录

我已经设法将弹出框添加到X图像,当我单击X时,消息框出现说OK删除或取消。然而,问题是当我点击OK和/或CANCEL时,两个按钮都会删除记录。

请帮助!

这是我得到的2个脚本。第一个脚本是tour_manage.php第二个脚本是delete_tour.php

<script type="text/javascript">
    function confirm() {
        if(r == true) {
            window.location='delete_tour.php;
        } else {
            window.location='tour_manage.php';
        }
    }
    </script>
<a href="delete_tour.php?tid=<?php echo $tid ?>" onclick="return confirm('Are you sure you want to delete this tour?');" ><img src="images/delete  
logo icon.png"  width="15" height="15"/></a></td>`
这是delete_tour.php脚本
<?php
session_start();
include('../config.php');
$id=$_GET['tid'];
$sql=mysql_query("delete from tour where tid='$id' ");
if($sql)
{
header('location:tour_manage.php');
}
?>

UPDATE

    <a onclick="return confirm('Are you sure you want to delete this tour?')"  href="delete_tour.php?tid=<?php echo $tid ?>">aaa</a>