How can a user delete a message he sends or the other user sends? Message should be shown only in the conversation of the one who hasn't deleted message.
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);
}
Hash is the conversation id started.