here is an except from the form:
Code: Select all
while ($mail = mysql_fetch_array($query)) {
echo '<tr class="mailbody">'
, '<td width=5><input type="checkbox" name="deleWhatId[]" value="'.$mail[id].'"></td>';
}Code: Select all
$_POST[deleWhatId][0] = $_POST[deleWhatId][0] == '' ? $_POST[deleWhatId] : $_POST[deleWhatId][0];
$countwhat = count($_POST['deleWhatId']);
//if there are actually some elements checked
if ($countwhat) {
//loops through all elements and deletes if that mail belongs to this person BASTARDS try to <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> with it huh?
for($i=0; $i<$countwhat; $i++) {
$findMail = mysql_query("SELECT fid, uid FROM mail WHERE id='$_POST['deleWhatId'][$i]'");
$mail = mysql_fetch_array($findMail);
if (($_POST[act1] == 'itwassent' || $_GET[act1] == 'itwassent') && $mail[fid] == $user[id]) {
mysql_query("UPDATE mail SET wher='2' WHERE id='$_POST['deleWhatId'][$i]'");
$whereFrom = 'Sent Folder';
} elseif ($mail[uid] == $user[id]) {
mysql_query("DELETE FROM mail WHERE uid='$user[id]' AND id='$_POST['deleWhatId'][$i]'");
$whereFrom = 'Inbox';
} else {
$errorMsg = 'There was an error processing your request, the mail did not belong to you.<BR>';
}
}
if ($errorMsg) {
echo '<font color=red>',$errorMsg,'</font>';
} else {
echo '<center><font color=green>You have deleted ',nFormat($i),' piece(s) of mail from your ',$whereFrom,'<BR><BR></font></center>';
}
}