myrepublic
asked on
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.c om"; // 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.docum ent.write( data);
document.layers.cust.docum ent.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(counte r.number.v alue);" 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-9 a-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);\ ">« Back</a></h3>"; exit; }
}
}
If(!$Message){error('Messa ge');}
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,"Fr om: $Name<$Email>\r\nReply-To: $AdminEmail\r\n");
}
}
?>
</body>
</html>
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.c
$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.docum
document.layers.cust.docum
}
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(counte
</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;"
<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.
}
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]([-_.+]
$friend=$i+1;
echo"<h3>The email $friend, <br><strong>$f[$i]</strong
}
}
If(!$Message){error('Messa
echo"<h3>Thanks.!.!</h3>";
for ($i= 0; $i <= $count; $i++) {
mail($f[$i], $Subject, $Message,"From: $Name<$Email>\r\nReply-To:
}
If(isset($MailToMe)){
$msg= "Name: $Name
Email: $Email
--------------------------
Mails sent to:\n";
$msg .=implode("\n", $f);
$msg .="\n---------------------
mail($AdminEmail,"$Subject
}
}
?>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry, i have no idea about php
ASKER
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
I guess this is more php related - though do you have any idea how to fix this?
Thanks,
AL