...

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



Saz
05-15-2008, 08: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.

Saz.

_Aerospace_Eng_
05-15-2008, 08: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.

Saz
05-16-2008, 08: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.

Saz.

syosoft
05-16-2008, 08: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.



<?php
# Mini-config
session_start();
$friend_limit = 3;

function validate_form() {
$found = 0;

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

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

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'] == '') :
continue;
endif;

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

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

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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum