I have an admin area where i can send emails to any selected member using using checkboxes. On submission it sends you to the next page where the email is then sent. All the emails that have been selected are then displayed

eg
mark@ntlworld.com Mail successfully sent!
uk@ntlworld.com Mail successfully sent!

The message is already built into the page so on parse the pre formatted email is sent.

what I want is contact form where I can select the members/all then on submission you are then linked to the contact form where a new subject/message can be written.

I have tried this so far within the code

print_r($_POST['email'];
produces

Array ( [0] => mark@ntlworld.com [1] => uk@ntlworld.com )

foreach($_POST['email'] as $key => $value) {
//echo "<input type='text' size ='20' name='' value = '$value'>";
}

or not echoing out within html

<input type='text' size ='20' name='' value = '<? echo $value; ?>'>

what this does it creates two seperate text boxes but what i want is one text box with all the emails selected within,

eg

<input type='text' size ='20' name='' value = 'mark@ntlworld.com;uk@ntlworld.com'>

the email separated by ;

I can then set the subject and message and sent hopefully to all selected.

any help would be greatly appreciated

thanks

roscor

    $emails = implode(";", $_POST['email']);
    $textbox = "<input type='text' size ='20' name='' value ='". $emails ."'>";
    
    echo $textbox;

    what implode does is takes an array eg($_POST['email']) and combines into 1 text string using the first parameter, in your case the ; ... so now all the emails will be listed in 1 string...like [email]email1@msn.com;email2@hotmail.com[/email] etc..

      That's great Shawnk. I have used explode when dealing with arrays but never implode. many thanks!

      roscor

        Hi again,

        I have been using the aforementioned with great success except that my email to those selected shows everyone else's email address also. I have tried incorporating a foreach() but I get the invalid error,
        I have been playing around with the code for several hours with no luck, I'm sure the answer is very simple,

        Any suggestions ?

        <? session_start();
        
        $email = implode(";", $_POST['email']);
        
        ?>
        
        <table>
        <form name="form1" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
        
              <tr>
                <td>&nbsp;</td>
                <td align="left" valign="top" class="sel4">Emails:</td>
                <td height="25" align="left" valign="top" class="text"><input type="text" name="email"  id="email" style="width: 200px; height: 18px" value ="<? echo $email; ?>"></td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td align="left" valign="top" class="sel4">Subject:</td>
                <td height="25" align="left" valign="top" class="text"><input type="text" name="subject" id="subject" style="width: 200px; height: 18px" value ="<? echo $subject; ?>"></td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td align="left" valign="top" class="text">Message:</td>
                <td height="25" align="left" valign="top" class="text"><textarea name="message" id="message" style="width: 250px; height: 120px" value ="<? echo $message; ?>"></textarea></td>
                <td>&nbsp;</td>
              </tr>
               <tr>
                <td>&nbsp;</td>
                <td align="left" valign="top" class="text"></td>
                <td height="25" align="left" valign="top" class="text"><input type="submit" name="submit" value="send"> <input type="reset" name="Reset" value="Reset"></td>
                <td>&nbsp;</td>
              </tr>
        </form> </table>
        <?
        if($_POST['submit']=="send") {
               $email =$_POST['email'];
               $subject=$_POST['subject'];
               $message=$_POST['message'];
        
        $headers = "From: info@?????.co.uk\r\n";
        $headers = "Reply-to: info@????.co.uk\r\n";
        $headers .= 'Content-Type: text/html';
        
        // Send Mail
        $rc = mail($email, $subject, nl2br($message), $headers); 
        
        }
         if ($rc) {
              echo($email.' <font face ="verdana" size="2"> Mail successfully sent!<br>');
        
        }
        else {
        die(print "<font face ='verdana' size='2'>Failed to send mail<br>Go <a href='back.php'>Back</a> and try again</font>");
        }
        
        ?>
          Write a Reply...