Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    sending mail to multiple users

    Hey, i have an online game, where you can send private messages to one another... i want to alter it so that you can put in the 'To' form: user1, user2 and it would send to both users.

    my code now:

    PHP Code:
            $username_to $_POST['a_username_to'];



     

                
    $result1 mysql_query("SELECT * FROM userinf WHERE username='$username_to'"$db);

                
    $retval1 mysql_fetch_array($result1);



            
    $subject trim(strip_tags($_POST['subject']));

            
    $message strip_tags($_POST['message']);



            if(!
    strlen($subject)) { $subject "(none)"; }

            if(!
    strlen($message)) { $err .= "No message supplied. "; }

            

            
    $result mysql_query("SELECT bactiv FROM userinf WHERE username='$username_to'"$db);

            if(!
    mysql_num_rows($result)) { $err .= "Player not found. "; }

            else {

                    
    $retval mysql_result($result,'bactiv');

                    if(
    $retval!='1') { $err .= "Player is blocked, and cannot recieve messages. "; }



                    if(
    strlen($err)<3) {

                            
    mysql_query("INSERT INTO mailinf(userfrom,rtime,username_to,subject,message) VALUES ('".$userinf['username']."','".time()."','$username_to','$subject','$message') "$db); 
    Please help ASAP, thanks

  • #2
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts
    can someone please help me... i need this badly

  • #3
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    I don't even see a call to the mail() function in the code you pasted.

  • #4
    Regular Coder
    Join Date
    Nov 2004
    Location
    Edinburgh, SCO
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts
    @ Fumigator:

    I think he is talking about PMs like on Forums, not actually emails.

    @king2k5:

    If you get the TO-string as a POST variable, try using regular expressions or explode() to get the names of the users. From that you would have to write a look-up function that would look up the ID of the users the PM should be sent to. Then just add multiple entries into the DB with that message (for, foreach loop)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •