"<div class=""post-text"" itemprop=""text"">
<p>I have a function where I get all information in my users. At the end of the string, I give the admin the option to delete the user, based on the users id.</p>
<p>My string:</p>
<pre><code>while ( $row = $result->fetch_assoc () ) {
$string .= ""<tr><td>"" . $row ['id'] . ""</td><td>"" . $row ['first_name'] . ""</td><td>"" . $row ['last_name'] . ""</td><td>"" . $row ['email'] . ""</td><td>"" . $row ['role_name'] . ""</td><td>[<a href='delete.php?id="" . $row ['id'] . ""'>Delete</a>]</td></tr>"";
}
</code></pre>
<p>My delete page:</p>
<pre><code>if ($user->deleteUser($_GET['id']))
{
header(""Location: admin.php"");
}
else
{
echo ""Could not delete the user!"";
}
</code></pre>
<p>And my delete user function:</p>
<pre><code>public function deleteUser($id)
{
$sql = ""DELETE FROM users WHERE id = ?"";
if (!$result = $this->db->mysqli->prepare($sql))
{
return false;
}
if (!$result->bind_param('i', $id))
{
return false;
}
return $result->execute();
}
</code></pre>
<p>And all of this works fine. </p>
<p>What I wan't to know, is how can I promt admin with an alert, saying: ""Are you sure?"" for example. </p>
</div>"
如想从上面代码段抽取出代码,有没有大佬救救孩子