Internet marketing resources, ecommerce web site design tutorials and  just for fun - free cell phone ringtones!
  Taming the Beast - quality web marketing and ecommerce development services

Tell a friend script update

Posted by Michael Bloch in web development (Wednesday September 20, 2006 )

We’ve just updated both versions of our popular Taming the Beast Tell-A-Friend scripts to v1.3 and v2.1; so if you’re using a copy of either from prior to today, I suggest updating. Upgrading is pretty simple – and of course, both scripts are still free :).

The new versions have improvements to security and may also address some of the random glitches on certain server setups I’ve seen cropping up from time to time.

Like the previous versions, these updated scripts have been kept as simple as possible for easy implementation.

If you’re currently using either of our recommendation scripts, you won’t need to change your input forms if going from v1.2 -> v1.3 or from v2 -> v2.1, just the form processing script component – but remember to personalize the indicated sections in the form processor.

The difference between the two recommendation scripts:

Tell A Friend Script v 1.3 is a very basic form and script which allows your visitors to send a link to your site to up to 3 of their friends. Simple code for a popup window to display the form is also included. You can customize the email their friends will receive and you also receive notifications when the form is used.

Tell A Friend Script v 2.1 does the same as v1.3, but has a feature that includes the URL of the page from where the tell a friend link was clicked in the recommendation email. In the notification you receive, you also see from which page the form was invoked.

If you have any questions regarding the scripts, I’d appreciate you reading the troubleshooting FAQ and if that doesn’t provide a solution; post your queries below, rather than emailing me directly. That way the answers to frequently asked questions can be available for everyone’s benefit :). Please read over other people’s questions and my responses in the thread below before posting – you may find the answer already there.

Need more features?

If you’re looking for a recommendation script with more features, try Tell A Friend King. It allows you to create tell a friend forms quickly and easily with a point and click interface, there’s no complex scripting, incorporates solid spam prevention, tracks and monitors usage, allows for pre-defined messages (text and HTML) or for users to enter their own and much more!

September 2007 – Given this thread has been around for a while, it’s accumulated quite a lengthy number of comments, questions and solutions; so I’ve just deleted many of the comment entries to consolidate everything into a troubleshooting FAQ of sorts – should save you some reading :)

By the way, thanks to everyone for your feedback and positive comments on these free recommendation scripts! It’s really been pleasing to see how broadly they’ve been used over the years!


Issue 1 – Should FTP upload mode be type be binary or ASCII?

Solution – ASCII, but most ftp programs should autodetect this anyway.

Issue 2 – When submitting the form the next page just shows the contents of the script.

Solution – this usually means your hosting account doesn’t support PHP

Issue 3 – when submitting the tellafriend form, the resulting page shows an error like this:

>>> Warning: Cannot modify header information – headers already sent by.. etc.

Solution – This usually occurs if you have characters before < ?php at the beginning of the script or after ?> at the end of the form processing script – even spaces can do it at times.

Issue 4 – Form submits correctly, but you don’t receive the test email

Possible solutions

a) There’s extra characters in the script that have been added in by the editor you’re using, but they don’t appear when viewing the script in the editor. Packages like Dreamweaver, FrontPage and Golive are notorious for this. Try using notepad or another plain text editor and you may see extra characters such as Ê at the end of some lines which shouldn’t be there; remove those characters as they will interfere with the operation of the script.

b) Your test emails have been filtered out by your email service provider. Check your bulk folders.

c) On rare occasions I’ve found some hosting services with restrictions in place that prevent mail function from working. It’s worthwhile sending the script to your host and asking them if there’s anything at the server level that would be preventing the emails from being sent.

Issue 5 – You want the popup to show scroll bars, resize etc

Solution – You can change settings in the manually triggered popup by changing values like this:

scrollbars=0 to scrollbars=1

Issue 6 – Version 2.x doesn’t show the referring URL in the recommendation email while you are testing.


a) If you’re just going straight to the form while you are testing, there would be no referring URL :). The form needs to be linked to from your site pages in order to capture the referrer information.

b) Version 2.1 of the script requires that the form be saved as .php (not .htm, html etc.) as it has php scripting elements in it in order to capture the URL of the referring page.

Issue 7 – You’d like to add an extra field so users can add their own comments

Solution – The reason why we haven’t added this is that it would be abused by some of the more anti-social visitors who might visit your site. It allows them to send abusive emails to people and cover their tracks. We may create a version 3 in the future with this option though.

By the way, if you decide to add extra fields or customizations yourself that are beyond what the script is currently designed to do; sorry, but I can’t help you with any issues you may experience as a result.

If you’d like to be notified of updates to the Tell a Friend scripts; please subscribe to our free newsletter – subscription box is towards the top of this this page in the left hand menu.


93 comments for Tell a friend script update
  1. Michael – great script. I’m experiencing the same problem as a few others – the recommended emails only go out to the friends if all 3 fields are completed. Is this something to do with the second @email function looking for values (email addresses) that don’t exist, therefore the entire email fails? We may need two layers of “ifs” to allow for one or two values not being received from the referrer form.

    Comment by John — October 17, 2007 @ 4:44 am

  2. Hi – may have answered my own question. It adds a function to see if fmail2 ans fmail3 are empty, then sends out the emails accordingly. It’s probably not the prettiest PHP you’ll see, but it seems works for me anyway.

    # This sends the note to the addresses submitted
    function check_not_empty($s, $include_whitespace = false)
    if ($include_whitespace) {
    // make it so strings containing white space are treated as empty too
    $s = trim($s);
    return (isset($s) && strlen($s)); // var is set and not an empty string ”

    if (check_not_empty($_POST[‘fmail1’],1) && check_not_empty($_POST[‘fmail2’],1) && check_not_empty($_POST[‘fmail3’],1)) {
    @mail(“$_POST[fmail1],$_POST[fmail2],$_POST[fmail3]”, $tsubject, $ttext, “FROM: $_POST[email]”);

    } elseif (check_not_empty($_POST[‘fmail2’],1)) {
    @mail(“$_POST[fmail1],$_POST[fmail2]”, $tsubject, $ttext, “FROM: $_POST[email]”);

    } elseif (check_not_empty($_POST[‘fmail3’],1)) {
    @mail(“$_POST[fmail1],$_POST[fmail3]”, $tsubject, $ttext, “FROM: $_POST[email]”);

    } else {
    @mail(“$_POST[fmail1]”, $tsubject, $ttext, “FROM: $_POST[email]”);
    # After submission, the thank you page
    header(“Location: $thankyoupage”);

    Comment by John — October 17, 2007 @ 9:44 am

  3. Hi John, thanks for posting that workaround – I’m really not sure why it does that on some setups and not on others. I’ll need to consult with some uber-geeks about it; but I’m sure your efforts will be appreciated by others experiencing the issue until I can do so :).

    Comment by Michael Bloch — October 18, 2007 @ 5:51 am

  4. Hi,

    my Tellafriend message is supposed to be sent in Slovak language. But then a problem occurs, the message comes in with some chars that cannot be read, as they are replaced for some weird stuff. The problem characters are e.g. ť or ž. Is there any way how to cope with the char set???

    Thany for help.

    Comment by Mickey — October 21, 2007 @ 11:59 am

  5. Step 1 – The Tell a Friend script
    Copy and paste the code below (from ) into Notepad and then save as “tellafriend.php”. The only items you really need to change are the “$emailto” information and also your site URL. Both of these are in bold below.

    not sure what you mean by into noteapd and save as php? how do i save as php in notepad?

    Comment by John — October 25, 2007 @ 9:54 pm

  6. It works…sort of. Yahoo! places this restictions on php mail–you must specify a return address that is in your own domain. Since that is the case, can I still use this script? Thanks in advance.

    Comment by Andy — October 30, 2007 @ 9:45 am

  7. Hey Michael,

    I am getting the following error code when submitting the form:

    Parse error: syntax error, unexpected T_VARIABLE in /home/mmancini/rebuttalstickers-www/recommend/tellafriend.php on line 27

    (Similar to question #45 in this thread – but I didn’t see an answer to question #45)

    I looked around on line 27, but not sure what the problem is.

    Am I an idtiot, and either way, can you help?


    Comment by Stephen — October 30, 2007 @ 11:38 am

  8. Hi,

    I’m using script v2.1. Great script, easy to install and work with. I have one problem though, the e-mail that I get has blank URL i.e. all of the text come through but URL.

    I read the posts here to figure out what I’m doing wrong. Any help will be much appreciated.


    Comment by Archie — November 1, 2007 @ 6:23 pm

  9. Hello, Your code is excellent. Thank-you.

    I am noticing that some of the emails that people are sending to are bouncing due to incorrect addresses.

    I am receiving the bounce message, but wish that the sender was instead. Is there a way to make it so that if an email bounces, the sender receives the error message, and not me?

    -Thanks, Stephanie

    Comment by Stephanie — November 7, 2007 @ 5:29 pm

  10. I downloaded the script and all is well from my side, but the email is never received from the person sending the Tell A Friend message. Please advise. Thank you.

    Comment by David — November 8, 2007 @ 2:50 pm

  11. I’ve been receiving a large number of spam emails through the recommendation form submission. Does anyone else experience this? Is there a way to block them so only true emails come through?

    Any help is appreciated!

    Comment by Lauren — November 11, 2007 @ 2:01 pm

  12. I’m having the same problem as Andy. I have a Yahoo hosted site and everything works fine except the e-mails are never sent. I checked my .tmp directory and there is a mailError.log that says “From address not in member domain. Message not sent.” Any ideas? Thanks.

    Comment by Adam — November 16, 2007 @ 5:19 am

  13. Hi

    I’ve applied the “BCC” hack (item 1) but when tested I get a Mail Failure message
    “A message that you sent contained a recipient address that was incorrectly

    Bcc: missing or malformed local part (expected word or “

    Comment by Colin — November 21, 2007 @ 5:22 am

  14. I have tested script and everything works find. However i;m afraid of abusing script because i do not see any really effective method to prevent spamming.
    I would appreciate if further upgrade integrate captcha, sending max 2-3 forms per ip address and also sending of ip address to owner of website (if same ip address abuse form then it is easy to block it)
    Tell a friend script call for abusing and spamming. Every extra integrated security is appreciate.

    Comment by Deny — November 25, 2007 @ 2:35 pm

  15. PHP is creating a strange error.

    Parse error: syntax error, unexpected ‘.’ in /usr/www/users/alexb/pghbizcal/tellafriend.php on line 76

    For those who are counting:-) line 76 is

    # This sends the note to the addresses submitted

    in the original script. Not a “.” in sight.

    The process starts at:

    Ideas are welcome..

    Comment by Alex — November 26, 2007 @ 8:39 pm

  16. John from #52…I think that I am having the same problem but where did you insert that code fix…under, over or instead of what the orginal was? Thanks so much!
    PS – website is totally under construction for someone…just trying to get this working.

    Comment by Nicole — November 26, 2007 @ 10:00 pm

  17. I am having the same issue as CJ any advise?

    I am using it a bit differently possibly, only edit to the code i made was i changed the code to reflect this

    i use the script in a greybox and the url detection didn’t work in the process of using it.

    also i have a quick question on the BCC hack… when i use it no1 gets the emails when i disable it i have to put all 3 emails in to get the emails sent out, tried 1 2 and 3 emails with the BCC hack and nothing. please advise

    Comment by Ken — November 28, 2007 @ 2:06 am

  18. Hi , I,m using the Tell-A-Friend script V 2.1 but it only seems to work with Firefox browser and not Internet Explorer?
    Could anyone shed any light on this problem please?

    Comment by paul — November 28, 2007 @ 10:36 am

  19. Michael,

    Thanks for the free script – it would be even more awesome if I could get it to work! :)

    I’m experiencing the same issue as #57, getting this error when submitting the form on a test page:

    PHP Parse error: parse error in E:\web\popdesigngroup\mcd\cashless\tellafriend.php on line 27

    I’m sure there is a simple explanation, but I can’t figure out why it isn’t working.

    Thanks for your help.

    Comment by Jen — November 30, 2007 @ 3:20 pm

  20. great little nifty script. I got it working within 15 minutes. Everything is running smoothly except some issues with accentuated characters in the messages received in Outlook. All é chars are interpreted as é . I changed the form page charset back and forth from utf-8 to iso-8859-1 but with no results.
    All the other pages in the website are using iso-8859-1 as default charset and working fine.
    I tried using é instead of é in the messages texts but that didn’t work either.
    Any hints on how to solve this?

    Kind regards

    Comment by FireWolf — December 2, 2007 @ 9:57 pm

  21. Hi, your script works fine on Firefox, but I.E.6 and 7 don´t shows the recommended URL.

    Can you say me whats wrong?

    Comment by Olaf — December 4, 2007 @ 11:21 am

  22. Problem fixed – it was the JS code…

    Many THX – Great Script

    Comment by Olaf — December 4, 2007 @ 1:00 pm

  23. Hello, thank you for providing this great script. Can you please tell me how to change the submit button to a graphic. I tried changing it but the script would stop validating and then it would render the thank you page.

    Much appreciated!
    Warm regards,

    Comment by Martha — December 6, 2007 @ 2:49 am

  24. Dear Michael,

    Thank you for a great script and great support to those of us who are having problems.

    My problem is the same as Sunil #48
    The script is running nicely and returning my thank you page. But no mails go out to either me or the friends. Has anyone solved this problem? My server provider is scratching his head not understanding what can be wrong. I have saved the php in notepad (published it through sharepoint-the new name of frontpage)but I can’t see any hidden characters.
    The starting page is


    Comment by Camilla — December 6, 2007 @ 5:40 am

  25. any ideas chief? i really really like the script just can’t figure out having to have all 3 filled in.

    Comment by Ken — December 6, 2007 @ 9:15 pm

  26. Hello,
    Great script. I just have a small problem. Everything seems to work but the thank you page is displayed in the pop-up. Is there a way to get the pop-up to close when submitted and then the underlying page go to the thankyou.htm?
    If that is too hard, how about just shutting the pop-up after the form is submitted?
    The site is
    The link is towards the top.

    Comment by David — December 8, 2007 @ 11:46 pm

  27. I did a quick workaround and modified my thank you page to automatically close by adding:

    Crude but this works.

    Comment by David — December 8, 2007 @ 11:59 pm

  28. hi,
    i am a student and have started working on php as a hobby.please forgive me if my question sounds stupid but it would be a graet help if you could help me out.your tell a friend php is great. i dont use any professional web host i just tested it on my own computer.I have a Apache development server running on my computer with php 5.the thank you page is shown when i click submit but i do not get any there any other software i should add to get a tell a friend to work.please hep me out.

    Comment by amy — December 9, 2007 @ 2:20 am

  29. hi sorry for the second post but i forgot to add that i am running the apache and php on windows vista .

    Comment by amy — December 9, 2007 @ 2:25 am

  30. Youch, quite a few questions have piled up – sorry that I haven’t been helping out recently folks, things have been really hectic. OK, if you’re still having problems and want some assistance; just add to this thread the the response number of your original report. Please check the troubleshooting guide first before doing so as the answer to your problem may be in there :).

    Comment by Michael Bloch — December 11, 2007 @ 5:18 pm

  31. My original question was #74. However it turned out to be the server settings after all. The mails are sendt and recieved now

    However. I am now trying to use the advanced script and the url is not being refered. The recomandation mail actually reads:

    …thought you may be interested in this web page.

    Is there something wrong with the javascript?

    The link is found at:

    Recommend this page;

    help appreciated

    Comment by Camilla — December 12, 2007 @ 8:18 am

  32. Hi Michael
    Don’t know if you could help me. Love the script idea, but for some reason I can only get one of the emails to be sent – I get the email listing who has recommended a page, and what page they recommended, but I can’t seem to get it to fire the emails to the friend. I have downloaded the v2.1. I wondered if it was to do with blacklisting, but my IP is clean. Can you help?
    The link to the script is:

    I’m not technical, but have only (as far as I recall) changed the email address as requested.

    Best wishes,

    Comment by Simon — December 12, 2007 @ 11:16 am

  33. Hey i just started to use your code. I can get the email function to work correctly but it will not show me the thank you page. I am getting this:
    Warning: Cannot modify header information – headers already sent by (output started at /home/wgdwxoi/public_html/conferenceiq/tellafriend.php:7) in /home/wgdwxoi/public_html/conferenceiq/tellafriend.php on line 134

    Is there a way that you can help me out with this?

    Thanks Eric

    Comment by Eric — December 13, 2007 @ 12:28 pm

  34. I like the script. Made all the substitutions as directed in the instructions. pop-up form comes up okay, but after I hit the “send” button I get a window which reads:


    The page you tried to access does not exist on this server. This page may not exist due to the following reasons:

    1. You are the owner of this web site and you have not uploaded (or incorrectly uploaded) your web site. For information on uploading your web site using FTP client software or web design software, click here for FTP Upload Information.

    2. The URL that you have entered in your browser is incorrect. Please re-enter the URL and try again.

    3. The Link that you clicked on incorrectly points to this page. Please contact the owner of this web site to inform them of this situation.

    Went back to make sure I installed everything as per the directions and still no go. Help!

    Comment by eric — December 14, 2007 @ 12:48 am

  35. I’m still working on this but I’m getting this error:

    The server encountered an unexpected condition which prevented it from fulfilling the request.
    The script had an error or it did not produce any output. If there was an error, you should be able to see it in the error log.

    Comment by alak — December 15, 2007 @ 6:20 pm

  36. Camilla – not sure on this – I can see the http_referer and print refurl coding in the source, which I shouldn’t be able to. It’s as though PHP isn’t working; although it must be if the message goes through, which it does. You mentioned server settings being an issue before – what was the issue?

    Ken, I haven’t played with the Bcc hack as yet, so I’m not sure.

    Amy, might be an issue with your php mail() function:

    Simon, I just tried out your script and received the three emails without a problem

    Eric (no.1), the “cannot modify header” error usually occurs if you have characters before < ?php at the beginning of the script or after ?> at the end of the form processing script – even spaces can do it at times.

    Eric (no.2), Please post a link to where your form is

    Alak, sounds like a permissions issue – what are the permission on the form processing script at present?

    Comment by Michael Bloch — December 19, 2007 @ 4:59 am

  37. Hi Michael,

    The issue with the serversettings before was that he had to choose which smpt server the mail was to be sendt from. The simple script works and as you say the advanced script also sends the mail, only lacking the url. Thats why I thought it might be the javascript, but I really have no idea…

    Comment by camilla — December 19, 2007 @ 6:27 am

  38. Hi…sorry I need a little help because I’m a complete novice! I copied the 2 parts of the script and saved in BBedit. I’m not quite understanding where these scripts should be placed….in a separate directory or in the directory of the page I want to use it on? Does the tellafriend.php code get copied into the head of the page you want to use it on or is just a script that sits in a directory and gets linked to? Oh, boy, I’m lost! I get where to link to the recform on a page with the pop up code…but the tellafriend.php…not sure where this comes in. Please help! THANKS!!!

    Comment by Alyssa — December 20, 2007 @ 5:15 pm

  39. Hi Michael,

    I answered my own lame question (#87) abd I’m able to get a pop-up rec form and fill out the form, but then I get an error message (same for some others posting on this thread) on submit:

    Parse error: parse error, unexpected T_VARIABLE in /home/socsnail/public_html/wla/includes/tellafriend.php on line 47

    I didn’t see an answer anywhere…do you know what the problem is?

    Comment by Alyssa — December 23, 2007 @ 2:33 am

  40. Alyssa, that usually you have some characters in the coding that shouldn’t be there. Which text editor did you use to configure the script?

    Camilla, I probably couldn’t help you much more on this without accessing your server to take a look and see what’s going one.

    Comment by Michael Bloch — December 23, 2007 @ 4:45 am

  41. Hi Michael…I figured it out..I had a quote facing the wrong way. I think it’s all working now, thanks! If I run into any more problems I’ll check back here. This has been such a helpful resource! ;)

    Comment by Alyssa — December 23, 2007 @ 7:15 pm

  42. Great to hear Alyssa :)

    Comment by Michael Bloch — December 24, 2007 @ 12:49 am

  43. Folks, I’m afraid I need to now close comments on this thread as unfortunately, I just don’t have time to answer questions about the app any more… gotta focus on putting food on the table ;). Check the troubleshooting guide in the post and also the other comments in this thread which may help you out if you’re stuck.

    Comment by Michael Bloch — August 17, 2008 @ 2:21 am

Sorry, the comment form is closed at this time.