Hi all,
I have developed a mysql database for maintaining info abt my machines.I want to give a confirm box if someone presses delete button.If the user presses ok,i proceed to delete the record otherwise I retain the same record.Can anyone help me out with this?Here's my code(sorry if it's long):

<html>
<head><TITLE>m2.php</TITLE>

<script type="text/javascript">
function disp_confirm()
{
var name=alert("Pressing delete would delete your record permanently.")
}
</script>

</head>
<body >
<form name="m2.php" method="POST">
<?
$reference=$_GET['ref'];

$db="database";
$link=mysql_connect("localhost","USERNAME","PASSWORD") or die("couldn't connect to Mysql");
mysql_select_db($db) or die("Select Error:".mysql_error());
$query="SELECT * FROM machines where ref='$reference'";
$rt=mysql_query($query);
$nt=mysql_fetch_array($rt);
$id = $nt['id'];
print "<table class=internal>";

print "<tr><td class=internal><b class=intro3>Ref:</b></td>
<td><input type=text name=ref value=$nt[ref] size=10></td></tr>";

print "<tr><td class=internal><b class=intro3>IP:</b></td>
<td><input type=text name=IP value=$nt[IP] size=20></td></tr>";

print "<tr><td class=internal><b class=intro3>MAC:</b></td>
<td><input type=text name=MAC value=$nt[MAC] size=20></td></tr>";

print "<tr><td class=internal><b class=intro3>Name:</b></td>
<td><input type=text name=Name value=$nt[Name] size=20></td></tr>";

print "<tr><td class=internal><b class=intro3>Location:</b></td>
<td><input type=text name=Location value=$nt[Location] size=20></td></tr>";

print "<tr><td class=internal><b class=intro3>Authority:</b></td>
<td><input type=text name=Authority value=$nt[Authority] size=20></td></tr>";

print "<tr><td class=internal><b class=intro3>Operative:</b></td>
<td><input type=text name=Operative value=$nt[Operative] size=10></td></tr>";

print "<tr><td class=internal><b class=intro3>MachineType:</b></td>
<td><input type=text name=MachineType value=$nt[MachineType] size=20></td></tr>";

print "<tr><td class=internal><b class=intro3>Processor:</b></td>
<td><input type=text name=FreqProcessor value=$nt[FreqProcessor] size=20></td></tr>";

print "<tr><td class=internal><b class=intro3>Hard Disk:</b></td>
<td><input type=text name=HardDisk value=$nt[HardDisk] size=10></td></tr>";

print "<tr><td class=internal><b class=intro3>Memory:</b></td>
<td><input type=text name=Memory value=$nt[Memory] size=10></td></tr>";

print "<tr><td class=internal><b class=intro3>Operating System:</b></td>
<td><input type=text name=OS value=$nt[OS] size=20></td></tr>";

print "<tr><td class=internal><b class=intro3>Other Operating System:</b></td>
<td><input type=text name=OtherOS value=$nt[OtherOS] size=15></td></tr></table>";

print "<table><tr><td><td><input type=submit name=Delete value=Delete ></td></tr></table>";

mysql_close($link);

if(isset($_POST['Delete'])){

echo "<SCRIPT LANGUAGE='javascript'>";
echo "var name=confirm('This will delete your record permanently');";
echo "if (name==true){";

[RIGHT]$db="database";
$link=mysql_connect("localhost","USERNAME","PASSWORD") or die("couldn't connect to Mysql");
mysql_select_db($db) or die("Select Error:".mysql_error());
$query="SELECT * FROM machines where ref='$reference'";
$rt=mysql_query($query);
$nt=mysql_fetch_array($rt);
$id = $nt['id'];

$recdel="delete from machines where id='$id'";
$recdel1=mysql_query($recdel);
mysql_close($link);[/RIGHT]

echo "redirTimer1();";
echo "}";
echo "else{ }";
echo "</SCRIPT>";

}
?>

</form>
</body>
</html>

    Please can someone help with this?I am not able to proceed further.Any help would be gratefully accepted.

      Write a Reply...