-1

I have MySQL table messages to allow users of my new site to send private messages to one another, while I was coding the message page I realize that if user1 send message to user2 and after sometime user2 decides to delete the message in he's inbox then the message from user1 inbox will also be deleted, I would like to be pointed on how can I figure this so user1 or user2 should only delete the message in he's inbox? Maybe this will needs to create every user table or what kind of concept is behind this?

I have tried multiple inserting with different ID's based on the people sending messages like sending one message two times to server so user1 should have he's own message also user2 but this besides being bad programming it seems not also be possible because in the html form the receiver can't change to be sender. I try to vice verse (swap) the variables on insetting .PHP page to get original receiver to sender, so I can just echo the messages using session user data but this is coursing the user2 to see all the messages like have been send by him while user1 sees the messages the way it suppose to be.

if my codes will be needed please let me know so I can provide.

4

1 回答 1

0

有一张桌子。将发件人、收件人、所有者和邮箱存储在不同的列中。

在允许删除消息之前检查要求删除消息的用户是否是所有者。( DELETE from messages WHERE message_id=? AND owner=?)。

发送消息时,将其存储两次。一次在发件人的已发送邮箱和收件人收件箱邮箱中。

于 2013-05-10T12:41:42.957 回答