title: Inbox and Outbox system with PHP and Mysql
body: <p>I created a Inbox and Outbox system on my website where users can send and receive text messages. </p>
  
  <p>I have created a tables in my DB</p>
  
  <p>-Messagebox </p>
  
  <p>MessageBox table contains the following 5 fields :</p>
  
  <pre><code> messageID Message SentBy SentTo Created 
  </code></pre>
  
  <p><strong>Inbox.php</strong></p>
  
  <pre><code> $you=$_COOKIE['username'];       $st= "SELECT* FROM Messagebox WHERE sentto='$you' ORDER BY ID DESC LIMIT 10";
  </code></pre>
  
  <p><strong>outbox.php</strong></p>
  
  <pre><code>  $you=$_COOKIE['username'];
  $st= "SELECT*FROM messagebox WHERE sentby='$you' ORDER BY ID DESC LIMIT 10";
  </code></pre>
  
  <p>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. </p>
  
  <p>If The sender deletes the messege from Outbox ,Or UserA deletes the message from Inbox ,Then the messege is deleted from both sides.</p>
  
  <p>How can I implement my system? </p>
  
  <p>Any help would be greatly appriciated!</p>