du42561 2014-04-08 19:24
浏览 174
已采纳

在重定向之前,如何提醒用户

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.

My string:

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>";
}

My delete page:

if ($user->deleteUser($_GET['id']))
{
    header("Location: admin.php");
}
else
{
    echo "Could not delete the user!";
}

And my delete user function:

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();
}

And all of this works fine.

What I wan't to know, is how can I promt admin with an alert, saying: "Are you sure?" for example.

  • 写回答

4条回答 默认 最新

  • dongwei2610 2014-04-08 19:32
    关注

    Use the confirm js function:

    <a href="delete.php?id=.." onclick="return confirm('are you sure?')">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 fluent无法启动
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。