Version: 1.0.0
Type: Full Script
Category: Other
License: GNU General Public License
Description: A simple php script that you can use on your site to allow others to recommend it to their friends. Comprised of one file and very easy to use.
<?php
/*
################################################################
#SV's Tell-A-Friend v1.0.o
#(c)SecondVersion (SecondV) www.secondversion.com
################################################################
#If you need help installing this script shoot me an email
#esizemore05@gmail.com
################################################################
#INSTALLATION
################################################################
#To install:
#
#Upload to your server. That's it!
#
################################################################
#TO USE
################################################################
#Use <?php include("tellafriend.php"); ?> where you want the
#form to be placed. This method requires that the page it's on
#be a .php page.
#
#OR
#
#Just place
#<a target="_blank" href="tellaform.php">Recommend this site</a>
#on your webpage and it will provide a link which will popup
#in a new window.
################################################################
*/
//Grab referer...
$ref = $_SERVER['HTTP_REFERER'];
//Our Form...
echo '
<form method="post" action="tellafriend.php">
Your Name:
<br>
<input type="text" name="name">
<br>
<br>
Your E mail address:
<br>
<input type ="text" name="email">
<br>
<br>
Friend Name:
<br>
<input type="text" name="fname">
<br>
<br>
Friend E mail address:
<br>
<input type ="text" name="femail">
<br>
<br>
Message:
<br>
<textarea name="message" rows="10" cols="70"></textarea>
<br>
<br>
<input type="submit" name="submit" value="Submit">
<br>
<br>
</form>';
if(!empty($_POST['submit']))
{
$name = $_POST['name'];
$message = $_POST['message'];
$email = $_POST['email'];
$fname = $_POST['fname'];
$femail = $_POST['femail'];
$validate = eregi("^[A-Z0-9.-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$", $email);
if(!$validate)
{
echo "Your email: " .$email. " is not a valid email<br>";
}
else
{
$e = $email;
}
if((empty($name)) || (empty($femail)) || (empty($fname)) || (empty($e)))
{
echo "All fields required. Please enter all data.";
}
else
{
//Send the data...
$name = stripslashes($name);
$fname = stripslashes($fname);
$subject = "Hey ".$fname." - Check out this cool site!";
$message = trim(stripslashes($message));
$message = strip_tags($message);
$msg = wordwrap($message, '70', '<br>\n');
$headers = 'From: '.$e.'';
mail("$femail", "$subject","
Hey $fname,
$msg
-------------------------------
You can check it out here:
$ref
", $headers);
if(!mail)
{
echo "Mail could not be sent";
}
else
{
echo "Mail sent, thanks for telling your friends about us!";
}
}
}
?>