2

我还是个新手。话虽如此,我的网站有一个消息系统,允许用户删除他们发送的消息。发现如果我从“已发送”框中删除我的邮件,它会从收件人收件箱中删除邮件。我有两种方法可以从您发送的邮件中删除邮件,“删除所有邮件”和一一删除。

这是我的全部擦除代码:

function deleteAll() {
    var answer = confirm('Are you sure you want to delete all of your messages?');
    if(answer){
        return true;
    }else{
        return false;
    }
}

if(isset($_POST['subEraseAll'])){

    $query = "UPDATE `Messages` SET `status` = 'dead' WHERE `sentFrom` = '".$auth->id."'";
    mysql_query($query,$connection) or die(mysql_error());

    <div class="EraseAll">
                                    <form name="EraseAll" action="SentMail.php" method="post" onsubmit="return deleteAll();">
                                    <input  type="submit" name="subEraseAll" value="Erase All Messages" />
                                    </form>
                                    </div>

下面是通过deleteConfirmPage一一删除消息的代码:

 $message = $_GET['id'];

    $query = "SELECT * FROM `Messages` WHERE `id` = '" . $message . "'";
    $request = mysql_query($query,$connection);
    $result = mysql_fetch_array($request);

    $toUser = $result['sentTo'];
    $fromUser = $result['sentFrom'];

    if($auth->id !=$fromUser) {
        header("Location: index.php");
        exit;
    }

    $query = "UPDATE `Messages` SET `status` = 'dead' WHERE `id` = '".$message."' LIMIT 1";
    $request = mysql_query($query,$connection);

那么,如何阻止我的查询从收件人收件箱中删除已发送邮件中的已发送邮件?

4

1 回答 1

2

为此,您可能需要更改表的结构,或更改使用“状态”列的方式。

这是一个潜在的解决方案,它提出了对表结构的更改,但如果没有更多信息,我无法确定它是否会起作用(甚至是相关的):


现在您的消息表只有一个“状态”列,它真正需要的是一个“状态发送者”列和一个“状态接收者”列。

当发送者删除消息时,将 'Status Sender' 值设置为 'dead',当接收者删除消息时,将 'Status Receiver' 设置为 'dead'

This means when you are displaying messages in a users inbox that you need to query for 'Status Reciever' = 'alive', and when you are displaying messages in a users sent folder, you need to query for 'Status Sender' = 'alive'.


Note: This design doesn't bode well for scenarios where a single user sends a message to multiple recipients.

于 2010-01-20T22:43:30.840 回答