I have this code in my mail system :
case "compose2":
$tomsg=str_replace("<","",$tomsg);
$tomsg=str_replace(">","",$tomsg);
$subject=str_replace("<","",$subject);
$subject=str_replace(">","",$subject);
$message=str_replace("<","",$message);
$message=str_replace(">","",$message);
$currentdate = date("Y/n/d g:i:s A");
$users_list=explode(';',$_POST['tomsg']);
$usersign = mysql_fetch_array(mysql_query("SELECT sign FROM players WHERE player_id='$pid'"));
if(isset($AttachSign)){
$fullmessage = "$message\n\n".$usersign['sign']."";
}else{
$fullmessage = "$message";
}
$request[0] = mysql_query("INSERT INTO mail (author, subject, date, content) VALUES('$pid','$subject', '$currentdate', '$fullmessage')");
foreach($users_list as $users){
$request[1] = mysql_query("SELECT id FROM mail WHERE author='$pid' AND date='$currentdate'");
$results[1] = mysql_fetch_array($request[1]);
$request[3] = mysql_query("SELECT player_id FROM players WHERE username='$users'");
$results[3] = mysql_fetch_array($request[3]);
mysql_query("INSERT INTO mail_link (player_id, message_id) VALUES('".$results[3]['player_id']."','".$results[1]['id']."')");
CleanMailBox($results[3]['player_id']);
}
header("Location: mail.php");
break;
As you can see , the player can add multiple user that will receive the message while using ; to separate users.
Here I need to check if
1) The user exists , because I don't want to add a blank entry in database.
2) Show to the user who is sending the message the usernames that didn't exists.
LIke , if I send a message to nick1 , nick2 , nick3 and nick4 , while nick4 is the only valid , I want to send the message to the user who is valid , so nick4 , and I want to print on the screen: The following message could not be delivered to the following person : nick1 , nick2 , nick3.
Can you help me to modify my request to add this?
case "compose2":
$tomsg=str_replace("<","",$tomsg);
$tomsg=str_replace(">","",$tomsg);
$subject=str_replace("<","",$subject);
$subject=str_replace(">","",$subject);
$message=str_replace("<","",$message);
$message=str_replace(">","",$message);
$currentdate = date("Y/n/d g:i:s A");
$users_list=explode(';',$_POST['tomsg']);
$usersign = mysql_fetch_array(mysql_query("SELECT sign FROM players WHERE player_id='$pid'"));
if(isset($AttachSign)){
$fullmessage = "$message\n\n".$usersign['sign']."";
}else{
$fullmessage = "$message";
}
$request[0] = mysql_query("INSERT INTO mail (author, subject, date, content) VALUES('$pid','$subject', '$currentdate', '$fullmessage')");
foreach($users_list as $users){
$request[1] = mysql_query("SELECT id FROM mail WHERE author='$pid' AND date='$currentdate'");
$results[1] = mysql_fetch_array($request[1]);
$request[3] = mysql_query("SELECT player_id FROM players WHERE username='$users'");
$results[3] = mysql_fetch_array($request[3]);
mysql_query("INSERT INTO mail_link (player_id, message_id) VALUES('".$results[3]['player_id']."','".$results[1]['id']."')");
CleanMailBox($results[3]['player_id']);
}
header("Location: mail.php");
break;
As you can see , the player can add multiple user that will receive the message while using ; to separate users.
Here I need to check if
1) The user exists , because I don't want to add a blank entry in database.
2) Show to the user who is sending the message the usernames that didn't exists.
LIke , if I send a message to nick1 , nick2 , nick3 and nick4 , while nick4 is the only valid , I want to send the message to the user who is valid , so nick4 , and I want to print on the screen: The following message could not be delivered to the following person : nick1 , nick2 , nick3.
Can you help me to modify my request to add this?