Search:
PHP
PHP Date Script
PHP Get Envelope Variables getenv(var)
PHP Page Counter Script
PHP Autoresponder Mailing Script
PHP Form to Email Script
Jay's PHP Recommend this Site Script
# Written by Jason Russo #
# http://thescriptcenter.com/
# LICENSE FREEWARE
###############################

Also known as Tell a Friend, refer a friend, recommend this site, this script will allow visitors to fill out a form and send an email to their friend(s) recommending your website.

Last Updated November 9th, 2008. Added usage stats.

Features:
  • Templates that allow you to fully integrate the script into your website.
  • Custom Messages and Error Codes. You can edit your error codes and messages so you can personalize every aspect of this script. NO annoying "script written by: " tagged at the end of your messages or embeded into your webpages.
  • Form Examples with plug and play code. I'll include form examples so that you can simply copy/paste the code right into your webpage.
  • Maximum uses per day feature! Help prevent spam and abuse by only allowing x-amount of uses to your website per day.
  • Maximum email address' set the maximum amount of email address visitors can send in to.
  • Block Domain Name extentions. Block .ru,.tk, domain or other domain name extentions to help cut down spam or target your geographic location.
  • Send Email via SMTP or standard PHP mail() function.
  • Usage Stats stores form data when your tell a friend script is used.

Requirements:
  • You'll need FTP, or SSH access to the server you plan to run the script from.
  • You'll need a basic understanding of how to upload the files to your server.
  • PHP 5.x or higher. This script hasn't been tested on a windows server and I don't believe it will run on windows at this time.
  • Form *MUST* have a field named email in order for it to function properly. <input type=text name=email>
  • Form *MUST* have a field named to_email in order for it to function properly. <input type=text name=to_email>
  • I recommend using the form example enclosed.
Form Demo

Download: tellafriend1.1.zip Number of downloads:

Instructions:

1.) Decompress(unzip) tellafriendX.X.zip to your local computer.

2.) Once the files have been unzipped you should see a folder named tellafriendX.X (X is the version you downloaded. IE: 1.0) Enter this directory then click on the templates directory. Edit the templates to fit your websites look/feel. Take care not to remove the variables in your templates I.E. <:<ERROR>:>

3.) Upload the folder with all of the contents to your web server.

4.) On your web server, enter the folder you just uploaded (tellafriendX.X). Enter the directory labeled "templates" change the permissions(CHMOD) to 777 on all the template files in that directory.

5.) Go up one directory; change the permissions(CHMOD) to 777 on the directory "includes", & file named "ip.txt"

6.) Enter the includes directory change the permissions(CHMOD) to 777 on the file jconfig.php, and usdb.php.

7.) (optional) Go up 2 directories or to your webroot folder, and rename your tellafriendX.X directory. You may rename this directory to whatever you wish: IE: contact, referafriend.

8.) Setting your variables. Load the admin script in your web browser: http://www.yourdomain.com/tellafriendX.X/form_admin.php . The default password is demo.

9.) Once logged in click on "settings"
Edit the following:
  • referrers: Separated by commas, this function will prevent spammers from entering an email address from your own domain name.
  • ademail: The Email address where the contents of your form will be sent.
  • blocked_domains: separated by commas, enter in the domain name extentions you wish to block from using your email script. IE: .ru,.tk will block any email from that domain name extention.
  • email_to_admin_subject: Administrative Email subject line when someone uses the script.
  • email_to_friend_subject: Email subject line of the person the visitor is sending to.(Bypassed if visitor fills in email_to_friend_subject field.)
  • email_to_client_subject: Email subject line to the visitor. (Only used if send_auto=1 or if send_auto is checked on form.)
  • req_fields: Requires a bit of skill. Separated by commas enter in any required fields on your form. I.E. first_name,address,phone However the field names *MUST* match these names exactely. If first name is a required field then you must have <input type=text name="first_name"> in order for this to function properly.
  • adminpass: The administrative password for form_admin.php
  • send_html_email: Send emails as HTML or plain text if off.
  • max_emails: Maximum amount of emails allowed in the "TO: " field on your form.
  • max_uses_per_day: How many times a user on your site is allowed to use the script. If they use it more than 1 or 2x, chances are they are just spamming;
  • send_auto: Send an autoresponse message to the visitor.
  • email_admin: Email Administrator when someone uses your script.
  • date_format: Shows current date. Uses PHP's date() variables. http://us3.php.net/manual/en/function.date.php;
  • time_format: Same as above;
  • use_ajax: Advanced users. If you are using Ajax to send the contents of your form set this to 1 See ajax_form_example.html for details;
  • error_invalid_admin_address: Error code shown when your admin address isn't valid. If you set up correctly, then there's no need for this error code.
  • error_email_from_same_domain: Sometimes spammers will attempt to spam your contact forms by entering an email address that is from your own domain. This little checker helps slow spam down so that you only get legitimate requests.
  • error_invalid_domain: Invalid Domain name extention. If the user tries to send an email from one of your blocked domain extentions, this is the message they will see.
  • error_invalid_email_address: Error code shown when the users email address is invalid or blank.
  • error_invalid_friend_email_address: Error code shown when one of the refferal email address is invalid or blank.
  • error_required_field_empty: Error code shown when a required field was left blank.
  • error_invalid_password: Error Code shown when your administrative password entered doesn't match the password in your config settings.
  • error_session_expired: Error code shown when your cookie has expired in your admin area.
  • usmtp: Use SMTP server or standard php's mail() function.
    • If above is turned on, then change the SMTP settings below.
    • auth: SMTP authentication.
    • helo: yourdomain.com
    • smtpuser: Username of the email address you'll be using
    • smtppass: SMTP password for this account;
    • host: usually your domain.com;
    • por: Standard SMTP port is "25";
  • template_ext: The template extention ".txt" by default. If advanced users wished to use .html extention templates instead you would change this variable.
##########################

10.) Copy and paste the form code from: sample_form.html.

UPGRADING: If you are upgrading from 1.0 to 1.1x.
1.) Download and unzip the new version to your local computer.
2.) Upload and overwrite the following files to your web server:
  • tellafriend.php
  • form_admin.php
  • templates/admin_default.txt
  • Upload to the includes directory usdb.php and change the permissions(CHMOD) to 777


####################################
## GLOBAL VARIABLES: ##
####################################
<:<FORM_CONTENTS>:> - Enter the contents of the form. <:<HTTP_USER_AGENT>:> - Gives you the web browser type.

<:<date>:> - Shows the date the script was accessed, according to the format you set in the date_format under your admin settings.

<:<time_format>:> - Shows the current time the script was used, according to the format you set in the time_format under your admin settings.

<:<ip>:> - Shows the IP address of the user who accessed the script.