View Full Version : Can anyone help with this tell a friend script please ?

05-15-2008, 09:03 PM
Been trying to setup a tell a friend script for quite a while, but can't seem to find the solution, am looking for a script that doesn't need js at all, where visitors can use the form to let up to 3 of their friends know about the website page that they are one (the website page automatically gets inserted into their form), and the forms get copied to the website owner, plus there's a short captcha, probably 2 digits and 2 letters.

Anyone come across a script like that at all please ?

Any help much appreciated.


05-15-2008, 09:10 PM
Have you checked hotscripts.com? I looked briefly but there isn't one that has all of the features you wanted. There is one that sends the link of the page to 3 friends but there is no captcha or what was sent to the site owner. Perhaps you should post in the work offers forum. I can make this for you btw.

05-16-2008, 09:07 AM
Thanks for that, but did check hs, and had nothing even close there, from what I could see.

I have placed this in the work offered forum as well.

Any help appreciated.


05-16-2008, 09:34 AM
Saz this might help you out, thou it doesnt address the captcha directly, it codes for it. You'll still need to plug in script that will set a session named captcha.

As always, completely untested. If nothing else, use as a starting point.

# Mini-config
$friend_limit = 3;

function validate_form() {
$found = 0;

foreach($_POST['friends'] as $friend) :
if(trim($friend['email']) != '') :

if($found == 0 || trim($_POST['captcha']) == '' || $_POST['captcha'] !== $_SESSION['captcha']) :
return false;

return true;

if($_POST) :
if($status = validate_form()) :
# Sending the email can be done 1 of two ways
# 1. Loop the post fields and send an individual email to each friend + admin
# 2. Send a single email with multiple to addresses and a bcc to the admin
# For simplicity, we're going with #2

$subject = 'From your friend';
$body = 'Visit this: http://myboguswebsite.com/';
$headers = array('From: Me <automated@myboguswebsite.com>', 'Content-type: text/plain', 'Bcc: admin@myboguswebsite.com');
$to = array();

foreach($_POST['friends'] as $friend) :
if($friend['email'] == '') :

if($friend['name'] != '') :
$to[] = $friend['name'].' <'.$friend['email'].'>';
else :
$to[] = $friend['email'];

if(!@mail(implode(',', $to), $subject, $body, implode("\r\n", $headers))) :
# Maybe say, failed to send emails? or just ignore it and pretend they were

die(header('Location: thank-you.php'));

if(isset($status)) :
echo '<div class="error">Complete the required fields</div>';
<form method="post" action="this-page.php">
for($i=0; $i<$friend_limit; ++$i) :
$required = $i == 0 ? ' <span class="required">*</span>' : '';
<label for="">Friends name:<?php echo $required; ?></label>
<input type="text" name="friends[<?php echo $i; ?>][name]" id="">
<label for="">Friends email:<?php echo $required; ?></label>
<input type="text" name="friends[<?php echo $i; ?>][email]" id="">
<?php endfor; ?>
<label for="">Captcha</label>
<img src="images/your-captcha-script.php">
<label for="">&nbsp;</label>
<input type="submit" value="Submit">