Publishing System Settings Logout Login Register
Tell A Friend Feature
TutorialCommentsThe AuthorReport Tutorial
Tutorial Avatar
Rating
Add to Favorites
Posted on March 3rd, 2008
7163 views
PHP Coding
Here's a great script i made, it's a brilliant way to get friends to refer friends to your site.

Working example: http://hearajoke.uni.cc/tellafriend

In this simple tutorial, i will explain to you how to make it:

tellafriend.php
<h1>Tell A Friend</h1> //Page title
Just type in your friends email address and we'll send them an email inviting them to join Hear A Joke.<br /> //Nice paragrah explaining what this page is.
You can send up to 5 invitations at ONCE! //Nice impressive ending!
<br />
<form action="tafprocess.php" method="post"> //Post Data
Friend 1: <input name="email1" type="text" /><br />//Goes through input boxes
Friend 2: <input name="email2" type="text" /><br />
Friend 3: <input name="email3" type="text" /><br />
Friend 4: <input name="email4" type="text" /><br />
Friend 5: <input name="email5" type="text" /><br />
<input type='submit'>
</form>


Then the process page!

tafprocess.php
[code=php]<h1>Tell A Friend <span>Email Report</span></h1>
<?php
$email1 = $_POST['email1'];
$email2 = $_POST['email2'];
$email3 = $_POST['email3'];
$email4 = $_POST['email4'];
$email5 = $_POST['email5'];
?>

<?php
$to = "$email1";
$subject = "Your Friend Has Invited You To yousite.com";
$body = 'You have been invited to yousite.com by your friend,

Please visit YourSite at http://yousite.com (You may need to copy the address into your browser)

Thank You Very Much
We cannot wait to see you there.';
if (mail($to, $subject, $body)) {
echo "$email1 - Sent<br />";
}else{
echo "Friend 1 - Failed<br />";
}
?>

<?php
$to = "$email2";
$subject = "Your Friend Has Invited You To yousite.com";
$body = 'You have been invited to yousite.com by your friend,

Please visit YourSite at http://yousite.com (You may need to copy the address into your browser)

Thank You Very Much
We cannot wait to see you there.';
if (mail($to, $subject, $body)) {
echo "$email2 - Sent<br />";
}else{
echo "Friend 2 - Failed<br />";
}
?>

<?php
$to = "$email3";
$subject = "Your Friend Has Invited You To yousite.com";
$body = 'You have been invited to yousite.com by your friend,

Please visit YourSite at http://yousite.com (You may need to copy the address into your browser)

Thank You Very Much
We cannot wait to see you there.';
if (mail($to, $subject, $body)) {
echo "$email3 - Sent<br />";
}else{
echo "Friend 3 - Failed<br />";
}
?>

<?php
$to = "$email4";
$subject = "Your Friend Has Invited You To yousite.com";
$body = 'You have been invited to yousite.com by your friend,

Please visit YourSite at http://yousite.com (You may need to copy the address into your browser)

Thank You Very Much
We cannot wait to see you there.';
if (mail($to, $subject, $body)) {
echo "$email4 - Sent<br />";
}else{
echo "Friend 4 - Failed<br />";
}
?>

<?php
$to = "$email5";
$subject = "Your Friend Has Invited You To yousite.com";
$body = 'You have been invited to yousite.com by your friend,

Please visit YourSite at http://yousite.com (You may need to copy the address into your browser)

Thank You Very Much
We cannot wait to see you there.';
if (mail($to, $subject, $body)) {
echo "$email5 - Sent<br />";
}else{
echo "Friend 5 - Failed<br />";
}
?>[/code]

The script above sends the email to each person and reports back wether the email was valid and sent or if nothing was inputed and failed.

Thank you for reading my tutorial.

Sponsored By HearAJoke.uni.cc
Dig this tutorial?
Thank the author by sending him a few P2L credits!

Send


This author is too busy writing tutorials instead of writing a personal profile!
View Full Profile Add as Friend Send PM
Pixel2Life Home Advanced Search Search Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Pixel2life Homepage Submit a Tutorial Publish a Tutorial Join our Forums P2L Marketplace Advertise on P2L P2L Website Hosting Help and FAQ Topsites Link Exchange P2L RSS Feeds P2L Sitemap Contact Us Privacy Statement Legal P2L Facebook Fanpage Follow us on Twitter P2L Studios Portal P2L Website Hosting Back to Top