I am using a php recommend a friend script that also places the information the user supplies into a text file.
However I am having a few minor problems and was wondering if someone could check the script for me..or improve it/offer a similar solution.
The text file is populated every time, but only certain emails seem to get through and the email is also supposed to contain a url, which it doesn't...
The script is as follows:-
<?
// Change the variable below to "no" if you do not wish to write
// the data to a text log
$logging="yes";
// Enter the website administrators email address here
$adminaddress = "test@test.com";
// Enter the company name or site name here
$sitename = "Test";
// Enter the address of your website here
$siteaddress ="http://www.test.com";
?>
<html>
<head>
<title>Tell A Friend</title>
<?php
IF ($action=="") {
?>
<?
$referer = getenv("HTTP_REFERER");
print "<p><B>$referer</B><BR><BR></p>";
?>
<p>To send the URL of this page and a brief message to friends who might like it, just fill out the
form below.
<BR>
<BR><FORM METHOD=POST ACTION="<? echo "$PHP_SELF"; ?>">
<TABLE BORDER="0" CELLSPACING="3" CELLPADDING="3">
<TR>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Your Name:</FONT></TD>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"
SIZE="3"><INPUT TYPE="text" NAME="yname"></FONT></TD>
</TR>
<TR>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Your Email:</FONT></TD>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"
SIZE="3"><INPUT TYPE="text" NAME="yemail"></FONT></TD>
</TR>
<TR>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Friend #1 Name:</FONT></TD>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"
SIZE="3"><INPUT TYPE="text" NAME="fname[1]"></FONT></TD>
</TR>
<TR>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Friend #1 Email:</FONT></TD>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"
SIZE="3"><INPUT TYPE="text" NAME="femail[1]"></FONT></TD>
</TR>
<TR>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Friend #2 Name:</FONT></TD>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"
SIZE="3"><INPUT TYPE="text" NAME="fname[2]"></FONT></TD>
</TR>
<TR>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Friend #2 Email:</FONT></TD>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"
SIZE="3"><INPUT TYPE="text" NAME="femail[2]"></FONT></TD>
</TR>
<TR>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Friend #3 Name:</FONT></TD>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"
SIZE="3"><INPUT TYPE="text" NAME="fname[3]"></FONT></TD>
</TR>
<TR>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Friend #3 Email:</FONT></TD>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"
SIZE="3"><INPUT TYPE="text" NAME="femail[3]"></FONT></TD>
</TR>
<TR>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Friend #4 Name:</FONT></TD>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"
SIZE="3"><INPUT TYPE="text" NAME="fname[4]"></FONT></TD>
</TR>
<TR>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Friend #4 Email:</FONT></TD>
<TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"
SIZE="3"><INPUT TYPE="text" NAME="femail[4]"></FONT></TD>
</TR>
<TR>
<TD VALIGN="TOP" COLSPAN="2"><FONT FACE="Arial, Helvetica, Verdana, Sans
Serif" SIZE="-1">Additional Comments:</FONT></TD>
</TR>
<TR>
<TD VALIGN="TOP" COLSPAN="2"><FONT FACE="Arial, Helvetica, Verdana, Sans
Serif" SIZE="3"><textarea NAME="comments" rows="3"></TEXTAREA></FONT></TD>
</TR>
<TR>
<TD VALIGN="TOP" COLSPAN="2"><FONT FACE="Arial, Helvetica, Verdana, Sans
Serif" SIZE="3"><INPUT TYPE="hidden" NAME="url" VALUE="<? echo "$referer"; ?>"><INPUT
TYPE="submit" NAME="action" VALUE="Send"></FONT></TD>
</TR>
</TABLE>
</FORM>
<BR>
<BR>
<BR>
<BR>
<BR>
<?
} ELSEIF ($action="Send") {
if (($yname=="") || ($fname=="") || ($femail=="")|| ($yemail=="")) {
print "Please use your back button and complete all of the required form fields, then resubmit.<br><br><br><br><br><br><br><br><br><br><br>";
} else {
print "Your recommendation to the following people has been sent:<br><br> ";
// cycle through the emal addresses and names
$items="5";
$tally="";
for ($numitems=0; $numitems < $items; $numitems++) {
if (($fname[$numitems]!="") && ($femail[$numitems]!="")) {
mail("$femail[$numitems]","$yname went to $sitename and recommended you check this out","$fname[$numitems] \n\n $yname stopped by $sitename and thought you would find the following URL of interest:\n \nURL: $url \n\n Additional Comments: \n------------------------------------ \n$comments \n------------------------------------\n\nThank you! \n$sitename \n$adminaddress \n$siteaddress","FROM:$yemail");
IF ($logging=="yes") {
$filename="url-log.txt";
// Nothing needs ot be changed here
$fl=fopen($filename,"a+");
// sets the pipe delimiters
fwrite($fl," '$url'|'$femail[$numitems]'|'$yemail'|'$comments'\
n");
fclose($fl);
}
$tally.="$fname[$numitems], ";
}
}
?>
<P>Your recommendation has been sent to <?php echo "$tally"; ?> </p>
<p><B><A HREF="<? echo "$url"; ?>">GO BACK</A></B> </p>
<BR>
<BR>
<?
}
}
?>