如何删除PHP和MySQL中的消息?

时间:2013-09-03 23:25:51

标签: php mysql

用户如何删除他发送的邮件或其他用户发送的邮件?消息应仅显示在未删除消息的人的会话中。

if($action == 'delete_mess') {

    $hash=$_GET['hash'];
    $mess_id=$_GET['mess_id'];

    $mess_query=mysql_query("SELECT * FROM messages WHERE hash = '$hash'");

    while($check_mess = mysql_fetch_assoc($mess_query)) {

        $from = $check_mess['from_id'];
        $to = $check_mess['to_id'];
    }

    if ($from == $session_user_id) {

        mysql_query("UPDATE messages SET from_del = 1 WHERE `id` = '$mess_id' ");

    } else {

        mysql_query("UPDATE messages SET to_del = 1 WHERE `id` = '$mess_id' ");
    }

    header('location: messages.php?hash='.$hash);
}

哈希是开始的对话ID。

0 个答案:

没有答案