I got the mail function working but have another problem.
I have a script that recommends a site on a web page. It uses two files refer6.html and refer6.php. (see below for the script of both files.
The script allows someone to recommend up to four people. It stores the results in a txt file and then it emails the recommendations and out puts to the browser.
It does all this with some problems. It does not send all four emails. It also repeats a message in the browser for each recommended person. I will like this not to repeat itself, but list only the emails to and form.
I tried also to see if I could get the script to redirect back to the website, nut I keep getting the following message:
Warning: Cannot add header information - headers already sent by (output started at /home/lowcostc/public_html/refer7.php:2) in /home/lowcostc/public_html/refer7.php on line 13
E-mail sent to
robert4442@comcast.net from
robert4442@comcast.net, they now know how to save up to 70% on their prescription drugs from lowcostcanadianrx.com
I tried moving the hearder script to just before the echo so it is called before the output to the browser., but it does not work.
I also have tried to define more variables like:
$subject=”Put subject Txt here”;
$body=”put your message here”;
I wanted to put $subject in the line -- mail("$email[$numitems]", "Save up to 70% on your prescription drugs!", "Hi – to replace save up to 70% on your prescription drugs!
And to I want to put $body in place of the text that starts with – Hi $friendsfirstname[$numitems]: I recently found a way to save up to 70% on my prescription drugs. I thought you would like to know how also. Please visit $siteaddress.
$sendersfirstname $senderslastname
This is my first try at a script this involved (for me anyway). Can someone help me?
Refer6.html:
<form action="refer6.php" method="post">
<table width="81%" border="0" cellpadding="5" align="center">
<tr>
<td><b><font size="5">*</font>Required </b></td>
</tr>
</table>
<table width="82%" border="0" cellpadding="5" align="center" bgcolor="#00CCFF">
<tr>
<td width="24%">
<div align="right"><b>You</b></div>
</td>
<td width="40%">
<div align="right">First Name<b><font size="5">*</font></b>:</div>
</td>
<td width="36%">
<input type="text" name="sendersfirstname">
</td>
</tr>
<tr>
<td width="24%"> </td>
<td width="40%">
<div align="right">Last Name<b><font size="5">*</font></b>: </div>
</td>
<td width="36%">
<input type="text" name="senderslastname">
</td>
</tr>
<tr>
<td width="24%"> </td>
<td width="40%">
<div align="right">E-mail<b><font size="5">*</font></b>:</div>
</td>
<td width="36%">
<input type="text" name="senderemail">
</td>
</tr>
<tr>
<td width="24%">
<div align="right"><b>Friend #1</b></div>
</td>
<td width="40%">
<div align="right">First Name<b><font size="5">*</font></b>:</div>
</td>
<td width="36%">
<input type="text" name="friendsfirstname[1]">
</td>
</tr>
<tr>
<td width="24%"> </td>
<td width="40%">
<div align="right">Last Name<b><font size="5">*</font></b>:</div>
</td>
<td width="36%">
<input type="text" name="friendslastname[1]">
</td>
</tr>
<tr>
<td width="24%"> </td>
<td width="40%">
<div align="right">E-mail<b><font size="5">*</font></b>:</div>
</td>
<td width="36%">
<input type="text" name="email[1]">
</td>
</tr>
<tr>
<td width="24%">
<div align="right"><b>Friend #2</b></div>
</td>
<td width="40%">
<div align="right"> First Name:</div>
</td>
<td width="36%">
<input type="text" name="friendsfirstname[2]">
</td>
</tr>
<tr>
<td width="24%" height="39"> </td>
<td width="40%" height="39">
<div align="right">Last Name:</div>
</td>
<td width="36%" height="39">
<input type="text" name="friendslastname[2]">
</td>
</tr>
<tr>
<td width="24%"> </td>
<td width="40%">
<div align="right">E-mail:</div>
</td>
<td width="36%">
<input type="text" name="email[2]">
</td>
</tr>
<tr>
<td width="24%">
<div align="right"><b>Friend #3</b> </div>
</td>
<td width="40%">
<div align="right"> First Name:</div>
</td>
<td width="36%">
<input type="text" name="friendsfirstname[3]">
</td>
</tr>
<tr>
<td width="24%"> </td>
<td width="40%">
<div align="right">Last Name:</div>
</td>
<td width="36%">
<input type="text" name="friendslastname[3]">
</td>
</tr>
<tr>
<td width="24%"> </td>
<td width="40%">
<div align="right">E-mail:</div>
</td>
<td width="36%">
<input type="text" name="email[3]">
</td>
</tr>
<tr>
<td width="24%">
<div align="right"><b>Friend #4</b></div>
</td>
<td width="40%">
<div align="right"> First Name:</div>
</td>
<td width="36%">
<input type="text" name="friendsfirstname[4]">
</td>
</tr>
<tr>
<td width="24%"> </td>
<td width="40%">
<div align="right">Last Name:</div>
</td>
<td width="36%">
<input type="text" name="friendslastname[4]">
</td>
</tr>
<tr>
<td width="24%"> </td>
<td width="40%">
<div align="right">E-mail:</div>
</td>
<td width="36%">
<input type="text" name="email[4]">
</td>
</tr>
<tr>
<td width="24%"> </td>
<td width="40%">
<div align="right">
<input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="Reset">
</div>
</td>
</tr>
</table>
</form>
refer6.php:
<!---Begin refer.php--->
<?
//set variables
$sitename="lowcostcanadianrx.com";
$siteaddress="
http://lowcostcanadianrx.com";
$filename="url-log.txt";
//cycle through the email address and names
$items="5";
$tally="";
for($numitems=0;$numitems<$items;$numitems++){
if(($friendsfirstname[$numitems]!="")&&($friendslastname[$numitems]!="")&&($email[$numitems]!="")){
//php mail function
mail("$email[$numitems]", "Save up to 70% on your prescription drugs!", "Hi $friendsfirstname[$numitems]: I recently found a way to save up to 70% on my prescription drugs. I thought you would like to know how also. Please visit $siteaddress.
$sendersfirstname $senderslastname", "From: \"$sendersfirstname\" $senderslastname \"$senderemail\n");
echo "E-mail sent to $email[$numitems] from $senderemail, they now know how to save up to 70% on their prescription drugs from $sitename";
//Logging to a file
//Be sure to upload the blank test file that the data will write to. I this case it is called url-log.txt
$fl=fopen($filename,"a+");
fwrite($fl,"'$sitename'|'$friendsfirstname[$numitems]'|'$friendslastname[$numitems]'|'$email[$numitems]'|'$sendersfirstname'|'$senderslastname'|'$senderemail'\n");
fclose($fl);
$tally="$friendsfirstname[$numitems],";
}
}
?>
<!---End refer.php--->
the header section is:
header("Location:
http://lowcostcanadianrx.com/");
where do I put this to work. It most likely will do away with the echo script section.