Delete script
need help
In the delete script the delete option is working after twice or thrice button clicks and both delete and cancel buttons are working in the same action. But usually Cancel should not function as delete.
here is the php script
<?php
$link = mysql_connect("localhost", "root", "")
or die("Could not connect: " . mysql_error());
mysql_select_db('taskmangment', $link)
or die ( mysql_error());
switch ($_GET['action']) {
case "delete":
$sql = "DELETE FROM AddJob WHERE note_id='" . mysql_real_escape_string($_GET['id']) . "'";
$result = mysql_query($sql)
or die("Invalid query: " . mysql_error());
break;
default:
$note = "";
break;
}
?>
<html>
<head>
<title>Delete</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script type="text/javascript">
function RefreshParentWindow()
{
if (window.opener && !window.opener.closed)
{
window.opener.location.reload();
self.close();
}
}
</script>
</head>
<body>
<center>
Are you sure do you want delete this?
<form name="Form1" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
<input type="submit" name="SUBMIT" value="<?php echo $_GET['action'];?>" onClick="RefreshParentWindow()" >
<input type="submit" name="SUBMIT" value="Cancel" onClick="RefreshParentWindow()" >
<?php
echo "
<input type='hidden' name='action' id='action' value='".$_GET['action']."' >
<input type='hidden' name='type' id='type' value='change' >
<input type='hidden' name='id' id='id' value='".$_GET['note_id']."' >";
?>
</form>
</center>
</body>
</html>
Please help me
Thanks.
|