Amit Verma
Amit Verma

Reputation: 41219

Inbox and Outbox system with PHP and Mysql

I created a Inbox and Outbox system on my website where users can send and receive text messages.

I have created a tables in my DB

-Messagebox

MessageBox table contains the following 5 fields :

 messageID Message SentBy SentTo Created 

Inbox.php

 $you=$_COOKIE['username'];       $st= "SELECT* FROM Messagebox WHERE sentto='$you' ORDER BY ID DESC LIMIT 10";

outbox.php

  $you=$_COOKIE['username'];
$st= "SELECT*FROM messagebox WHERE sentby='$you' ORDER BY ID DESC LIMIT 10";

My problem is that When UserA sends a message to UserB ,UserA can see the message in Inbox and the Sender can see the sent message in his Outbox.

If The sender deletes the messege from Outbox ,Or UserA deletes the message from Inbox ,Then the messege is deleted from both sides.

How can I implement my system?

Any help would be greatly appriciated!

Upvotes: 1

Views: 1975

Answers (1)

Santosh Jagtap
Santosh Jagtap

Reputation: 1065

You can add two flags for delete purpose. One flag is for deletedByReceiver and another is for deletedBySender. Set the appropriate flag whenever message deleted.

Another option is to maintain on more table which maintain the our and in of each message with message id. For more go through : Messaging system in php mysql

Upvotes: 2

Related Questions