Hi there,
Firstly apologies as I know this is not technically the right forum but I am using PHP? Anyway I hope you can help.
Basically I have a table for internal user mail that has many rows including UserTo and mail_id. The function below is to delete a message my only problem being because I pass the mail_id through the URL it allows people to delete others mail and I am trying to patch it with the following:
I have tried using just the delete statement with the where and clause with some bugs. Can anyone suggest any better method to check the UserTo matches the current username AND the mail_id is correct before deleting or is this my best bet?
Any ideas,
Thanks
Firstly apologies as I know this is not technically the right forum but I am using PHP? Anyway I hope you can help.
Basically I have a table for internal user mail that has many rows including UserTo and mail_id. The function below is to delete a message my only problem being because I pass the mail_id through the URL it allows people to delete others mail and I am trying to patch it with the following:
Code:
function delete($msgid, $box){
global $database, $session;
$xxx = $database->query("SELECT UserTo FROM ".TBL_MAIL_INBOX." WHERE mail_id = '$msgid'");
$row = mysql_fetch_array($xxx);
$s = $row["UserTo"];
if($session->username == $s){
$q = "DELETE FROM ".TBL_MAIL_INBOX." WHERE UserTo = '$session->username' AND mail_id = '$msgid' LIMIT 1";
} else {
echo "This is not your mail!";
}
}
I have tried using just the delete statement with the where and clause with some bugs. Can anyone suggest any better method to check the UserTo matches the current username AND the mail_id is correct before deleting or is this my best bet?
Any ideas,
Thanks