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
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
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
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 <hello@mysite.com>' . "\r\n";
     if(mail($email,$subject,$message,$headers)&&$i<{
          $i++;
     }
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.