Jump to content

Number of emails


forumnz

Recommended Posts

Hi,

 

I am writing a script that send emails to up to 8 people, which uses emails provided by a user.

I have 8 boxes named memail1, memail2 etc up to memail3.

 

In the next page i have

$memail1 = $_REQUEST['memail1'] ; right up to $memail8 = $_REQUEST['memail8'] ;

 

I want to have a counter that counts how many have been submitted.

How do I do that?

 

Thanks,

Sam.

Link to comment
https://forums.phpfreaks.com/topic/82726-number-of-emails/
Share on other sites

Thanks! This is what I have now:

 

<?php
$email = $_REQUEST['email'] ; 
$name = $_REQUEST['name'] ; 
$memail = $_REQUEST['memail'] ; 
  
$memail = explode("\n",$_POST['textarea']);
$i = 0;
foreach($memail as $email){
     if(mail($subject,$to,$message)&&$i<{
          $i++;
     }
}  

echo $i;
  
?>

 

Only problem is, it always displays 1, even if I enter 5 emails.

Link to comment
https://forums.phpfreaks.com/topic/82726-number-of-emails/#findComment-420773
Share on other sites

Still doesn't work. This is my form:

 

<form action="email.php" method="post"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="12%">Name:</td>
    <td width="88%"><label>
      <input type="text" name="name" id="textfield" />
    </label></td>
  </tr>
  <tr>
    <td>Email:</td>
    <td><label>
      <input type="text" name="email" id="textfield" />
    </label></td>
  </tr>
  <tr>
    <td><p>Friends Emails:<br />
      (separate with </p>
    </td>
    <td><label>
      <textarea name="memail" id="textarea" cols="45" rows="5"></textarea>
      <br />
      <input type="submit" name="button" id="button" value="Submit" />
    </label></td>
  </tr>
</table></form>

 

and my code:

<?php
$email = $_REQUEST['email'] ; 
$name = $_REQUEST['name'] ; 
$memail = $_REQUEST['memail'] ; 
  
$memail = explode("\n",$_POST['textarea']);
$i = 0;
foreach($memail as $email){
     if(mail($subject,$to,$message)&&$i<{
          $i++;
     }
}  

echo count($memail);
  
?>

 

Help appreciated.

Link to comment
https://forums.phpfreaks.com/topic/82726-number-of-emails/#findComment-420797
Share on other sites

if you are using my mail function, I am really sorry, I formatted the function wrong.

 

<?php
$emails = explode("\n",$_POST['textarea']);
$i = 0;
$subject = "hello!!";

foreach($emails as $email){
     // To send HTML mail, the Content-type header must be set
     $headers  = 'MIME-Version: 1.0' . "\r\n";
     $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
     // Additional headers
     $headers .= 'To: ' . $email . "\r\n";
     $headers .= 'From: My Site <[email protected]>' . "\r\n";
     if(mail($email,$subject,$message,$headers)&&$i<{
          $i++;
     }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/82726-number-of-emails/#findComment-420988
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.