Thanks, its working great like that. However, I am having some trouble with the error displaying. I am trying to get it to show a line saying, "The user username does not exist" for each user they enter that doesn't exist. I get this error whenever I send the message:
Code:
Warning: Invalid argument supplied for foreach() in /home/bntqann/public_html/client_work/cms/ucp/includes/send.inc.php on line 34
Here is the code for my foreach statement:
PHP Code:
// Send to each user
$recipients = explode(',', $recipient);
foreach ($recipients as $recipient) { $recipient = trim($recipient);
//
// Check user
$qry = mysql_query("SELECT * FROM `users` WHERE user = '$recipient'") or die ("Error Checking User! \n<br />\n" .mysql_error());
$chk = mysql_num_rows($qry);
if ($chk < 1) { $error = trim($recipient); }
//
else {
$insert = mysql_query("INSERT INTO `pm` (id, recipient, sender, subject, message, status, date) VALUES ('', '$recipient', '$user', '$subject', '$message', 'unread', '$date')") or die ("Error Sending Message! \n<br />\n" .mysql_error());
echo('<meta http-equiv="refresh" content="3;URL=messages.php" /> <div class="message">Your message has been sent to '.$recipient.'<br /></div>');
}
}
// If Error Sending
if ($error) {
echo('<div class="error">');
foreach ($error as $r) {
echo('The recipient <b>'.$r.'</b> does not exist. <br />');
}
echo('</div> <a href="javascript:history.back();"><<Back</a>');
}
//
else { echo('<meta http-equiv="refresh" content="3;URL=messages.php" /> <div class="message">Your message has been sent.</div>'); }
I know its an error in the second foreach area, but I am not too familiar with using this type of thing, so I can't tell what it is. Anyone know? Thanks
Bookmarks