完全删除用户 [英] Delete user completely

查看:73
本文介绍了完全删除用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户或管理员想要从站点中完全删除该用户。您将如何设置查询以从包含用户ID的每个表/子表中删除该用户。这是我的带有子表的表的列表,其中单个用户的可能ID可能是。


  1. user

  2. 相册-user_id

  3. block- user1_id

  4. blogdata_comments-comment_poster

  5. blogdata_feedback-feedback_userid

  6. 朋友-user1_id或user2_id

  7. 消息-消息创建者或message_target

  8. 通知-通知目标用户或notification_triggeredby

  9. 照片注释-photo_comment_poster

  10. streamdata-streamitem_creator或streamitem_target

  11. streamdata_comments-comment_poster

  12. streamdata_feedback-feedback_userid

  13. userphotos-photo_ownerid


解决方案

@Dave我可能无法做到这一点,但我认为您可以做点什么



您显然需要在下面创建自己的非常基本的代码版本,但是它应该可以工作吗? / p>

编辑
只是认为ud已经需要其ip

  $ db =新的mysqli(主机,用户名 ,密码,数据库); 

$ removeUser =从(用户,专辑,块等)删除(用户ID在哪里)='$ user';

if(removeUser = $ db-> query($ removeUser)){
$ ipAddr = $ _SESSION ['REMOTE_ADDR'];
$ banList =插入禁止的(ipAddr)值('$ ipAddr')

die($ user。从所有表中删除);

if($ banList = $ db-> query($ banList)){
die($ user。添加到禁止列表);
} else {
die(向禁止列表添加。$ user。时出错);
}
}否则{
死亡(无法从所有表中删除用户);
}


If a user or an admin wanted to delete a user completely from the site. how would you go about setting a query to remove that user from every table/subtables where the users id is contained. Here is the list of my tables with the subtables where the possible id of an individual user could be.

  1. user
  2. albums - user_id
  3. block - user1_id
  4. blogdata_comments - comment_poster
  5. blogdata_feedback - feedback_userid
  6. friends - user1_id or user2_id
  7. messages - message_creator OR message_target
  8. notifications - notification_targetuser OR notification_triggeredby
  9. photo_comments - photo_comment_poster
  10. streamdata - streamitem_creator OR streamitem_target
  11. streamdata_comments - comment_poster
  12. streamdata_feedback - feedback_userid
  13. userphotos - photo_ownerid

解决方案

@Dave i could be way off the mark with this but i think you could do something like this which would also stop the user from creating a new account.

You would obviously need to make your own version of the very basic code below but it should work?

EDIT just thought ud need their ip already

$db = new mysqli ('host', 'username', 'password', 'database');

$removeUser = "DELETE FROM (user, albums, block, and-so-on) WHERE `user-id`='$user'";

if(removeUser = $db->query($removeUser)){
    $ipAddr = $_SESSION['REMOTE_ADDR'];
    $banList = "INSERT INTO banned (ipAddr) VALUES ('$ipAddr')"

        die($user . 'removed from all tables');

    if($banList = $db->query($banList)){
        die($user . 'Added to banned list');
    }else{
        die('Error adding ' . $user . ' to banned list');
    }
}else{
    die ('Unable to remove user from all tables');
}

这篇关于完全删除用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆