Hello, I am still a newbie.So that being said, my site has a messaging system that allows users to delete their sent messages. Its been discovered that if I erase my messages out of my 'sent' box, it erases the message out of the recipients inbox. I have two ways to delete messages out of your sent mail, 'erase all messages' and one by one.
Here is my code for the erase all:
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>
Here is the code to delete messages one by one via the 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);
So my question is how do I stop my query from erasing sent messages from my sent box out of the recipients inbox
Thank you!