|
Free tell-a-friend script - version 2.1
|
Script updated to version 2.1 September 19 2006
The popularity of our original free
tell-a-friend script has been amazing! People enjoy it's simplicity and
lightweight code; thanks to everyone for your feedback.
Since releasing the original
script, I have had many
requests for extra features; particularly for a function that sends the URL
of the page of where the tell a friend link was clicked. So, after a lengthy
delay, I'm pleased to present the Taming the Beast Tell A Friend Script
Version 2.0. I really must devise a shorter and catchier title one day
:)
Why use a tell a friend script?
Even in our high tech society where megabuck marketing tools
abound, word of mouth is still one of
the most powerful forms of marketing. People have a tendency to react
positively to recommendations from their friends and colleagues - it's as
simple as that. A single recommendation can snowball - Tom tells Jack, Jack
tells Jill and John, they each tell two people, etc.
By using a recommendation form on your site, a single
visitor can literally generate thousands more!
The beauty of word of mouth marketing via a tell a friend
script is that the investment is next to nil - just a little of your time to
implement the feature.
There are many recommendation/tell a friend scripts around
and I'm by no means saying that this one is the best; it's just simpler than
most, yet still very effective.
 |
Need a
More Powerful
Tell A Friend application?
* Highly customizable, create forms in seconds
* No complex scripting, spam prevention
* Tracks and monitors usage
* Easy to use admin panel
* Pre-define message
* Or allow users to enter their own
* Free trial, support and much more!..
Try
Tell A Friend King free today! |
|
Free recommendation script features
-
Lightweight script
-
Basic form validation rules
-
Easy to configure, there's only two parts - the PHP
script itself and the form
-
Allows a visitor to send a recommendation to 3 friends
-
Personalized subject line
-
Notifies you when someone has submitted the
recommendation form
-
Sends the URL of the current page in the recommendation email
-
Sends URL of the page recommended in a notification to
you
Try
it out - recommend this page If
you don't need the extra features of automatic referring page URL insertion
or personalization of subject lines, you may like to try our simpler,
original tell a friend
script. It's also a better choice where you want the form to appear
directly in current HTML pages as the input form itself in this version
requires PHP for the advanced referrer page feature.
Be
notified of Tell a Friend script updates!
Don't forget to sign up for our free newsletter to be informed of
Tell a friend script updates and new features! Simply enter your
name and email address at the top right hand side of this page! |
Tell a friend script requirements
What you will need to ascertain first before going any
further is whether your hosting plan supports PHP. If you're not sure, ask
your web host to save yourself the frustration of guessing - only to find out
that your plan doesn't support it.
If you are a FrontPage user, please remember to copy the
code below to a text editor such as Notepad first and then copy and paste it
from there into the FrontPage HTML source window. This will prevent
FrontPage from trashing the code.
Part 1 - the tell a friend processing script
Copy and paste the code below (from <?PHP to
?>) into Notepad and then save as "tellafriend.php". The only
items you really need to change are the "$emailto" information,
which is in bold.
It's also advisable to edit the body text of the email
(where indicated below) sent out to recipients with further
details about your site and to alter the subject line in the email the
recipients will receive to suit your needs.
--- do not copy this line, start from next line
<?php
// This following statement must not be changed.
// Copyright (c) Michael Bloch and Taming The Beast.
// Tell-A-Friend script V 2.1 Updated September 19 2006
// Taming the Beast.net - http://www.tamingthebeast.net
// Free Web Marketing and Ecommerce Resources and Tools
// By using this script you agree to indemnify Taming the Beast
// from from any liability that might arise from its use.
// The preceding statement must not be changed.
if(count($_POST)) {
# This part strips out nasty code that a malicious
# person may try to inject into the form
foreach(array('fmail1','fmail2','fmail3','email','name') as $key) $_POST[$key] = strip_tags($_POST[$key]);
if(!is_secure($_POST)) { die("Hackers begone");}
# This part submits a notification to you when
# the form is submitted
// Email address for copies to be sent to - change to suit
$emailto = "you@yoursite.com";
// Notification email subject text for copies
$esubject = "Recommendation form submission";
// Email body text for notifications
$emailtext = "
$_POST[name] has used your recommendation form using an email address of $_POST[email]
The people the recommendation has been submitted to are:
$_POST[fmail1]
$_POST[fmail2]
$_POST[fmail3]
The page recommended:
$_POST[refurl]
";
# This function sends the email to you
@mail("$emailto", $esubject, $emailtext, "From: $_POST[email]");
# This part is the function for sending to recipients
// Page to display after successful submission
// Change the thankyou.htm to suit
$thankyoupage = "thankyou.htm";
// Subject line for the recommendation - change to suit
$tsubject = "A web page recommendation from $_POST[name]";
// Change the text below for the email
// Be careful not to change anyt "$_POST[value]" bits
$ttext = "
Hi,
$_POST[name], whose email address is $_POST[email] thought you may be interested in this web page.
$_POST[refurl]
$_POST[name] has used our Tell-a-Friend form to send you this note.
We look forward to your visit!
";
# This sends the note to the addresses submitted
@mail("$_POST[fmail1],$_POST[fmail2],$_POST[fmail3]", $tsubject, $ttext, "FROM: $_POST[email]");
# After submission, the thank you page
header("Location: $thankyoupage");
exit;
}
# Nothing further can be changed. Leave the below as is
function is_secure($ar) {
$reg = "/(Content-Type|Bcc|MIME-Version|Content-Transfer-Encoding)/i";
if(!is_array($ar)) { return preg_match($reg,$ar);}
$incoming = array_values_recursive($ar);
foreach($incoming as $k=>$v) if(preg_match($reg,$v)) return false;
return true;
}
function array_values_recursive($array) {
$arrayValues = array();
foreach ($array as $key=>$value) {
if (is_scalar($value) || is_resource($value)) {
$arrayValues[] = $value;
$arrayValues[] = $key;
}
elseif (is_array($value)) {
$arrayValues[] = $key;
$arrayValues = array_merge($arrayValues, array_values_recursive($value));
}
}
return $arrayValues;
}
?>
--- do not copy this line; finish copying at above line
Part 2 - The tell a friend form:
Copy and paste the code below and save it as recform.php. This is the
submission form that your visitors
will use to recommend your site. The file needs to be saved into the same folder as
the tellafriend.php script. Customize the page to suit your site.
<html>
<head>
<title>Recommendation form</title>
<script language="javascript">
<!--
function reset() {
document.tellafriend.name.value="";
document.tellafriend.email.value="";
document.tellafriend.fmail1.value="";
document.tellafriend.fmail2.value="";
document.tellafriend.fmail3.value="";
}
function validate() {
if (document.tellafriend.fmail1.value.length==0) {
alert("Oops! you'll need to enter a friend's email address");
return false;
}
if (document.tellafriend.email.value.length==0) {
alert("Oops! you forget to enter your email address");
return false;
}
if (document.tellafriend.name.value.length==0) {
alert("Oops! you forgot to enter your name");
return false;
}
document.tellafriend.submit()
return true;
}
//-->
</script>
</head>
<body onload="reset()" topmargin="0" leftmargin="0">
<p>
<center>
</center>
<table width="450" cellpadding="0" cellspacing="0" align="center">
<tr valign="top">
<td valign="middle" align="center">
Complete the details below to send a link to the page:<br>
<? $refurl = $_SERVER['HTTP_REFERER']; ?>
<? print $refurl;?>
<form name="tellafriend" action="tellafriend.php" method="post" onsubmit="return checkfields()">
<div align="center">
<center>
<table border="0" cellpadding="10" cellspacing="0">
<tr>
<td> *your name:</td>
<td>
<input size="30" name="name" maxlength="45">
</td>
</tr>
<tr>
<td>*your email:</td>
<td>
<input size="30" name="email" maxlength="45">
</td>
</tr>
<tr>
<td colspan="2">
<p align="center">Enter your friend's email addresses:</td>
</tr>
<tr>
<td>*email 1:</td>
<td>
<input size="30" name="fmail1" maxlength="50">
</td>
</tr>
<tr>
<td>email 2:</td>
<td>
<input size="30" name="fmail2" maxlength="50">
</td>
</tr>
<tr>
<td>email 3:</td>
<td>
<input size="30" name="fmail3" maxlength="50">
</td>
</tr>
<tr>
<td colspan="2">
<p align="center">
The email that will be sent to will contain your name & email address. <br>
<input onclick="validate();" type="button" value="click once to send">
<input type=hidden name=refurl value="<? print $refurl;?>">
</td>
</tr>
</table>
</center>
</div>
</form>
</td>
</tr>
<tr valign="top">
<td valign="middle" align="center">
</td>
</tr>
</table>
</body>
</html>
Once you have these two files ready to go, create a thankyou.htm
page or specify another page to be used in part 1, upload the files to the
same folder and you're done! When you create a link to the form, set it to open in a
new window so your visitors don't lose the page they were on - or you can use
a popup window.
Calling the tell a friend form via a popup window
If you want to call the form via a popup window, it's very easy to do. Simply click the "Select All"
button below and then copy the code - remember to change the
"path/to/recform.php" statement in the code to suit. You can also change the
size of the popup window width and height attributes.
Troubleshooting the tell a friend script
The most common problems
-
Your hosting plan not supporting PHP
-
Permission error issues. If this occurs, set permissions to
755 or 750
-
Changing ""$_POST[value]"" values
-
Copying code directly from this page into FrontPage HTML
source code. Copy to notepad first.
-
Forgetting to change the "you@yoursite.com"
for notifications.
You'll also find a stack of other troubleshooting tips in my
tell
a friend script update blog post.
I hope you find this recommendation script useful and that
it brings you as many extra visitors as it has done for us!
Tip: get news of any updates to this Tell-a-friend
script by subscribing to our free newsletter via the box on the top right
hand side of this page!
Questions?
Unfortunately I don't have the time available to me to
answer individual questions about the script; but check this blog
post thread for other troubleshooting tips. Thanks!
Other learning resources
Tell a
friend script V1
Favorites icon tutorial
and bookmarking script
Creating custom
error pages
Choosing the best shopping
cart software
Michael Bloch
Taming the Beast
http://www.tamingthebeast.net
Tutorials, web content, tools and software.
Web Marketing, Internet Development & Ecommerce Resources
____________________________
This article is not available for reproduction without express written
permission. Details regarding articles that are available for reproduction
without written consent can be viewed in our tutorial
archive.
Click here to view article index
|