要在使用php从mysql中删除行之前放置警告触发器吗

要在使用php从mysql中删除行之前放置警告触发器吗,php,mysql,html,Php,Mysql,Html,我想在使用php从mysql中删除特定行之前发出警告,下面是我的代码请建议我应该如何做??删除脚本工作正常 这是我的用户删除.php <?php include("../includes/config.php"); ?> <?php if ($_SESSION["isadmin"]) { $con=mysql_connect($dbserver,$dbusername,$dbpassword); if (!$con) { die('Could not connect: '

我想在使用php从mysql中删除特定行之前发出警告,下面是我的代码请建议我应该如何做??删除脚本工作正常

这是我的用户删除.php

<?php include("../includes/config.php"); ?>
<?php

 if ($_SESSION["isadmin"])
{

$con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con) { die('Could not connect: ' . mysql_error()); }

mysql_select_db($dbname, $con);
$accountid=$_GET["id"];
$result = mysql_query("SELECT * FROM accounts WHERE (id='".$accountid."')");
while($row = mysql_fetch_array($result))
{
   $id=$row['id'];
   $firstname = $row['firstname'];
   $lastname = $row['lastname'];
   $password = $row['password'];
   $email=$row['email'];
   $type=$row['type'];
}
mysql_close($con);
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Delete User</title>
<link rel="StyleSheet" href="../admin/css/style.css" type="text/css" media="screen">
</head>
<body>
<?php include("../admin/includes/header.php"); ?>
<?php include("../admin/includes/nav.php"); ?>
<?php include("../admin/includes/manage-users-aside.php"); ?>
<div id="maincontent">

<div id="breadcrumbs">
    <a href="">Home</a> >
     <a href="">Manage Users</a> >
     <a href="">List Users</a> >
     Delete User
</div>
<h2>Delete User</h2>

<form method="post" action="users-delete-action.php">
<input type="hidden" value="<?php echo $accountid; ?>" name="id" />
<label>Email/Username:</label><input type="text" name="email" value="<?php echo $email;     ?>" /><br /><br />
<label>Password:</label><input type="password" name="password" value="<?php echo   $password;?>" /><br /><br />
<label>First Name:</label><input type="text" name="firstname" value="<?php echo   $firstname; ?>" /><br /><br />
<label>Last Name:</label><input type="text" name="lastname" value="<?php echo  $lastname; ?>" /><br /><br />
<label>Type:</label><br />
<input type="radio" name="type" value="S" <?php if ($type == 'S') echo   'checked="checked"'; ?> />Student<br />
<input type="radio" name="type" value="T" <?php if ($type == 'T') echo  'checked="checked"'; ?> /> Teacher<br />

    <input type="submit" value="Delete" />
</form>



</div>

</body>
<?php include("../admin/includes/footer.php"); ?>
</html>
<?php
}
else
{
    header("Location: ".$fullpath."login/unauthorized.php");

}
?>


在提交时使用此按钮:

<input type="submit" value="Delete" onclick="return confirmSubmit()" />

提交时附上确认

<form method="post" action="users-delete-action.php" 
 onsubmit="return confirm("Are you sure you wish to delete?");">

1解决方案就是修改表单:

    <form name="form" method="post" action="users-delete-action.php">
<input type="hidden" value="<?php echo $accountid; ?>" name="id" />
<label>Email/Username:</label><input type="text" name="email" value="<?php echo $email;     ?>" /><br /><br />
<label>Password:</label><input type="password" name="password" value="<?php echo   $password;?>" /><br /><br />
<label>First Name:</label><input type="text" name="firstname" value="<?php echo   $firstname; ?>" /><br /><br />
<label>Last Name:</label><input type="text" name="lastname" value="<?php echo  $lastname; ?>" /><br /><br />
<label>Type:</label><br />
<input type="radio" name="type" value="S" <?php if ($type == 'S') echo   'checked="checked"'; ?> />Student<br />
<input type="radio" name="type" value="T" <?php if ($type == 'T') echo  'checked="checked"'; ?> /> Teacher<br />

    <input type="button" value="Delete" onClick="if (confirm('Are you sure you want to delete ?')) document.form.submit(); return false;">" /> </form>​


我像你说的那样使用了它,但它不起作用。我是说它的用户没有任何警告。你应该检查页面上的javascript是否起作用。是的javascript还不起作用,我只是在使用php,是否有任何方法可以通过php使用警告?如果这不是放置此警告的好方法…我还应该做些什么来防止这种危险??上面提到的代码是javascript??我从未使用过java脚本…很抱歉,我应该在哪里使用document.forms[“form”].submit()<代码>文档.forms[“form”].submit()
在onClick事件中-
onClick=“if(confirm('您确定要删除吗?'))文档中。forms[“form”].submit();return false;“>”
我将一个工作代码的示例放在fiddle中-您可以检查代码,最好的方法是离开客户端验证(警报)并在php中进行第二次检查,不要以隐藏形式发送ID。这并不优雅,但您可以将变量存储在$\u会话全局中。而不是

    <form name="form" method="post" action="users-delete-action.php">
<input type="hidden" value="<?php echo $accountid; ?>" name="id" />
<label>Email/Username:</label><input type="text" name="email" value="<?php echo $email;     ?>" /><br /><br />
<label>Password:</label><input type="password" name="password" value="<?php echo   $password;?>" /><br /><br />
<label>First Name:</label><input type="text" name="firstname" value="<?php echo   $firstname; ?>" /><br /><br />
<label>Last Name:</label><input type="text" name="lastname" value="<?php echo  $lastname; ?>" /><br /><br />
<label>Type:</label><br />
<input type="radio" name="type" value="S" <?php if ($type == 'S') echo   'checked="checked"'; ?> />Student<br />
<input type="radio" name="type" value="T" <?php if ($type == 'T') echo  'checked="checked"'; ?> /> Teacher<br />

    <input type="button" value="Delete" onClick="if (confirm('Are you sure you want to delete ?')) document.form.submit(); return false;">" /> </form>​