Multiple Recipient Tell A Friend script - Firefox problems

Hi.
I have dug an old script out of my files for sending emails to multiple recipients - a basic Tell a Friend script.  It works fine in Internet Explorer though not in Firefox. I haven't tested on Mac.

You can specify how many recipients, click the update button and the email form fields appear (that's the idea anyway).

Can anyone help me fix this up for Firefox?

Thanks,

Al


Here's the code:

<?php
$Subject = "Subject"; //Subject of the mail sent out
$AdminEmail="me@mydomain.com";  // This is Your Email address
$MailToMe="1" // 0 - No, 1 - Yes
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb">
<head>
<title>Title</title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function createForm(number) {
data = "";    
inter = "'";
if (number < 16 && number > -1) {
for (i=2; i <= number; i++) {
if (i < 10) spaces="      ";
else spaces="    ";
data = data + "Friend " + i + " :" + spaces + "<input type='text' size=27 name='f[]' /><br>";
}
if (document.layers) {
document.layers.cust.document.write(data);
document.layers.cust.document.close();
}
else {
if (document.all) {
cust.innerHTML = data;
      }
   }
}
else {
window.alert("You can choose upto 15 emails.");
   }
}

//  End -->
</script>
<h3>Page Title</h3>
<?php
If(!$sub){
?>
                  <form name=counter>
                        Number of emails to send to:
                  <select name="number" class="red">
                    <option value="1" SELECTED>1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                    <option value="6">6</option>
                    <option value="7">7</option>
                    <option value="8">8</option>
                    <option value="9">9</option>
                    <option value="10">10</option>
                    <option value="11">11</option>
                    <option value="12">12</option>
                    <option value="13">13</option>
                    <option value="14">14</option>
                    <option value="15">15</option>
                  </select>
                  <input type=button value="Refresh" onclick="createForm(counter.number.value);" name="button" />
                </form>
                        
                        <form action="<?=$PHP_SELF;?>" method="POST" name="webform">
                        <ul>
                        <li>Your Name: <input type="text" name="Name" /></li>
                        <li>Your Email: <input type="text" name="Email" /></li>
                        <li>Write your emails <input type="text" name="f[]" />
                        <span id="cust" style="position:relative;"></span></li>
                        <li>Your Message: <textarea name="Message" cols="35" rows="5">Text here</textarea></li>
                        <li><input type="submit" name="sub" value="Send" /></li>
                        </ul>
                        </form>

<?php
} else{
      Function error($req){
      echo"<br><br><h3>$req needed<br><a href=\"javascript:history.back()\">&laquo; Back</a></h3>";exit;
            }
      If(!$Name){error('Name');}
      If(!$Email){error('Email');}
      if($f[0] == ""){error('Friend 1 Email');}
      $count= count($f);
      For ($i= 1; $i <= $count; $i++) {
      if (!$f[$i] == ""){
      if(!eregi("[0-9a-z]([-_.+]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,}$", $f[$i])) {
            $friend=$i+1;
            echo"<h3>The email $friend, <br><strong>$f[$i]</strong>, <br>appears to be invalid.</h3><br><h3><a href=\"javascript:history.back(-1);\">&laquo; Back</a></h3>"; exit; }
}
}
      If(!$Message){error('Message');}

            echo"<h3>Thanks.!.!</h3>";
            for ($i= 0; $i <= $count; $i++) {
                  mail($f[$i], $Subject, $Message,"From: $Name<$Email>\r\nReply-To: $Name<$Email>\r\n");
            }
            
If(isset($MailToMe)){            
$msg= "Name: $Name
Email: $Email
-------------------------------------------------------------------
Mails sent to:\n";
$msg .=implode("\n", $f);
$msg .="\n-------------------------------------------------------------------";
mail($AdminEmail,"$Subject",$msg,"From: $Name<$Email>\r\nReply-To: $AdminEmail\r\n");
}

}
?>
</body>
</html>
myrepublicAsked:
Who is Participating?
 
basicinstinctConnect With a Mentor Commented:
You could just change the JavaScript function to this:

function createForm(number) {
data = "";    
inter = "'";
if (number < 16 && number > -1) {
for (i=2; i <= number; i++) {
if (i < 10) spaces="      ";
else spaces="    ";
data = data + "Friend " + i + " :" + spaces + "<input type='text' size=27 name='f[]' /><br>";
}

document.getElementById('cust').innerHTML = data;

}
else {
window.alert("You can choose upto 15 emails.");
   }
}
0
 
myrepublicAuthor Commented:
Cheers basicinstinct - that works great!

I have a question re: an error message that appears after sending - although the emails send fine:

"No recipient addresses found in header"

I have changed the header info to this (previous header info also resulted in same error):

mail($AdminEmail,"Check it oot!",$msg,"MIME-Version: 1.0\r\nContent-type: text/plain; charset=iso-8859-1\r\nFrom: $Name<$Email>\r\nReply-To: $AdminEmailX-Priority: 1\r\nX-MSMail-Priority: High\r\nX-Mailer: sendmail");

I guess this is more php related - though do you have any idea how to fix this?

Thanks,

AL
0
 
basicinstinctCommented:
sorry, i have no idea about php
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.