我做了一个程序,将删除数据库中的记录,它正在工作,但程序会自动删除记录而无需确认。我希望我的程序在删除之前先确认,我该怎么做?
内容功能码:
//*********************************************************************
function Content()
{
if(isset($_POST['btnAdd'])) //if in case 'Add Entry' button is click
{
return DataEntryForm('');
}
else if(isset($_POST['btnSave'])) //if in case 'Save' button is click during adding new entry or editing
{
if($_POST['uname']=='')
{
return saveRecord();
}
else
{
return updateRecord();
}
}
else if(isset($_GET['edituname'])) //if in case 'Edit' is click
{
return DataEntryForm('Edit');
}
else if(isset($_GET['deluname'])) //if in case 'Delete' is click
{
return deleteRecord();
}
else if(isset($_POST['btnSearch'])) //if in case 'Search' is click
{
return viewRecord();
}
else
{
return viewRecord('');
}
}
删除记录功能码:
//***************************************************
// delete record
//***************************************************
function deleteRecord()
{
$uname=$_GET['deluname'];
$sql = "DELETE FROM users WHERE UserName='$uname'";
$result = mysql_query($sql) or die(mysql_error());
//-------------------------------------------
// Display notification if successful
//-------------------------------------------
$code = <<< htmlcode
<br/>
<br/>
<p align="center" border=0 style="font-family:verdana,helvetica; font-size:15px; color:green">
User successfully deleted.
</p>
<br/>
<center>
<form name="frmDataEntry" method="POST" action="" style="font-family:verdana,helvetica; font-size:12px;">
<table border=0 style="font-family:verdana,helvetica; font-size:12px;">
<tr>
<td>
<input type="submit" name="btnBack" value="    OK    " onClick ="frmDataEntry.action='DataEntry_List_Search.php'"/>
</td>
</tr>
</table>
</form>
</center>
<br/>
<br/>
htmlcode;
return $code;
}