Jump to content

[SOLVED] Tell a freind email script bugs - read evrything and stumped !


dfarrell

Recommended Posts

Hi  I have been battling with this php script for 3 days now !  doing my head in !!, 

 

Parse error: parse error, unexpected $ in /home/afforda1/public_html/tellafriend.php on line 84

 

code below  any help in clearing this up would be apprecited iv'e looked at all spaces etc and all I can think of

 

( IF NOT  then does anyone have a WORKING tell a friend script  where people can tell their freinds about a certain webpage ? and it fires off 3 emails to friends and sends a message to webmaster telling them form was used ?  )

 

Code starts here

<?php

ob_start();

// This following statement must not be changed.

// Copyright © Michael Bloch and Taming The Beast

// Tell-A-Friend script V 2.1 Updated September 19 2006

// Taming the Beast.net - http://www.tamingthebeast.net

// Free Web Marketing and Ecommerce Resources and Tools

// By using this script you agree to indemnify Taming the Beast

// from from any liability that might arise from its use.

// The preceding statement must not be changed.

if(count($_POST)) {

# This part strips out nasty code that a malicious

# person may try to inject into the form

foreach(array('fmail1','fmail2','fmail3','email','name') as $key) $_POST[$key] = strip_tags($_POST[$key]);

if(!is_secure($_POST)) { die("Hackers begone");}

# This part submits a notification to you when

# the form is submitted

// Email address for copies to be sent to - change to suit

$emailto = "referrals@affordablemortgages.co.uk";

// Notification email subject text for copies

$esubject = "Recommendation form submission";

// Email body text for notifications

$emailtext = "

$_POST[name] has used your recommendation form using an email address of $_POST

The people the recommendation has been submitted to are:

$_POST[fmail1]

$_POST[fmail2]

$_POST[fmail3]

The page recommended:

$_POST[refurl]

";

# This function sends the email to you

@mail("$emailto", $esubject, $emailtext, "From: $_POST");

# This part is the function for sending to recipients

// Page to display after successful submission

// Change the thankyou.htm to suit

$thankyoupage = "FREE_MoneySaving_Guide.pdf";

// Subject line for the recommendation - change to suit

$tsubject = "Recommended by $_POST[name] a FREE MoneySaving Debt advice guide";

// Change the text below for the email

// Be careful not to change anyt "$_POST[value]" bits

$ttext = "

Hi, its $_POST[name], I thought you may be interested in this FREE MoneySaving and Debt Advice Guide, I think its really good.

$_POST[refurl]

$_POST[name] has used our Tell-a-Friend form to send you this note.

We look forward to your visit!  -  You'd be MAD not to  - most people save around £350 per month by implementing as few as 3 of the 20+ tips.

- It's TOTALLY FREE  no gimmicks or sales pitch, 8 pages of tools and tips to help you reduce your debts and outgoings, all we ask is you 'spread the word' and help your friends as well.

 

";

 

# This sends the note to the addresses submitted

@mail("$_POST[fmail1],$_POST[fmail2],$_POST[fmail3]", $tsubject, $ttext, "FROM: $_POST");

 

# After submission, the thank you page

function Redirect($time, $thankyoupage) {

 

echo "<meta http-equiv=\"refresh\" content=\"{$time}; url={$thankyoupage}\" /> ";

 

}

 

# Nothing further can be changed. Leave the below as is

 

function is_secure($ar) {

$reg = "/(Content-Type|Bcc|MIME-Version|Content-Transfer-Encoding)/i";

if(!is_array($ar)) { return preg_match($reg,$ar);}

$incoming = array_values_recursive($ar);

foreach($incoming as $k=>$v) if(preg_match($reg,$v)) return false;

return true;

}

 

function array_values_recursive($array) {

$arrayValues = array();

foreach ($array as $key=>$value) {

if (is_scalar($value) || is_resource($value)) {

$arrayValues[] = $value;

$arrayValues[] = $key;

}

elseif (is_array($value)) {

$arrayValues[] = $key;

$arrayValues = array_merge($arrayValues, array_values_recursive($value));

}

}

return $arrayValues;

?>

Link to comment
Share on other sites

you error means that you are missing some syntax, usually a closing bracket ) or }. Also at a quick look you should be getting posted info like

 

$_POST['name'] and not like $_POST[name].

 

Also

 

you are saying $)POST[$key] which make no sense as $key is the results from some variables.

Link to comment
Share on other sites

Hi  thanks to the speedy replies  tried  both  )  didn't like that

and tried  }  which the came up with Parse error: parse error, unexpected $ in /home/afforda1/public_html/tellafriend.php on line 84

 

aslo emails aren't ebing sent is that normal  as before emails were coming through even though I was getting error messages ?

Link to comment
Share on other sites

Hi I have updated php scrip    new script below  works in so much that form appears and transfers through to next page  but no emails are being sent thriough ?

 

<?php

//You will need to configure the script. 

//It's easy, just use a text editor.

//Follow the instructions in the "Begin Configure" section below.

 

//Note: This script contains a link to our site. 

//We'd like it if you left it, but you have permission to remove it. :)

 

//This script uses the new $_POST and $_SERVER['HTTP_REFERRER']

//If you have an issue with an older version of PHP, you can get help at:

 

// ************Begin Configure***************

 

//Put your website name between the quotes below:

$websiteName = "Free MoneySaving guide";

 

//Put your website address between the quotes below:

$websiteAddress = "www.affordablemortgages.co.uk";

 

 

// If you have a privacy policy, put in the link title:

$privacyPolicyLinkText = "";

 

 

// Put in the "" the url to you your privacy policy, if you have one,

$privacyPolicyLinkURL = "";

 

 

// Change the 0 to a 1 below,

//if you want to recieve a notice when people are refered:

$notice = 1;

 

 

//Put your email address in the " " if you changed the notice to 1

$adminEmail = "davidf@affordablmortgages.co.uk";

 

 

//Put the subject line text you want the email to read in the  "":

$subject = "Free Guide MoneySaving Debt Advice Guide Recommended by me";

 

//Specify $login

$login = $_GET['login'];

 

// Put your default message intro text in the first set of quotes below

//This is what the people who are referred will see

//along with any personal message entered by the referer.

$defaultMessageIntro = " I Came across this FREE Moneysaving / Debt advice guide - I found it really useful you should have alook yourself and spread the word, it has 20 practical moneysaving tips tips in and a corker of a budgetting tool.";

 

//Put in the "" your default close (this will be at the end of the message):

$defaultMessageClose = " It really is FREE and no dodgy download !";

 

 

// ************End Configure****************

 

// Set the link that will be in intro/invite and used to send the referer back

if (isset($_POST['link'])) {

$link = $_POST['link'];

}

else {

if (empty($_SERVER['HTTP_REFERER'])) {

    $link = 'http://' . $websiteAddress;

} else {

    $link = $_SERVER['HTTP_REFERER'];

 

}

}

// Add the link to the intro

$defaultMessageIntro = $defaultMessageIntro . $link . "\n";

 

//Adds a space infront of the subject line (to add a name latter

$subject = ' ' . $subject;

?>

<?php

function doTellForm ($privacyPolicyLinkText, $privacyPolicyLinkURL, $defaultMessageIntro, $link)

{

// If you understand HTML, you can make changes to the form layout below.

// I just copy the HTML from the "<form" opening to the "</form>"

// Put it into Dreamweaver (WYSIWYG Editor), work on it and put it back.

$theForm = <<<EOD

<form name="tellForm" method="post" action="">

  <br /><br /><table width="500px" border="0" align="center" cellpadding="0" cellspacing="0">

    <tr>

      <td  class="main"width="50%"><div align="center">Your name:</div></td>

      <td  class="main"width="50%"><div align="center">Your email:</div></td>

    </tr>

    <tr>

      <td> <div align="center">

          <input class="main" name="your_name" type="text" id="your_name">

        </div></td>

      <td> <div align="center">

          <input class="main" name="your_email" type="text" id="your_email">

        </div></td>

    </tr>

    <tr>

      <td><div align="center"></div></td>

      <td><div align="center"></div></td>

    </tr>

    <tr>

      <td class="main"><div align="center"><br />Enter the name(s) of your friend(s):</div></td>

      <td class="main"><div align="center"><br />Enter the email(s) of your friend(s):</div></td>

    </tr>

    <tr>

      <td> <div align="center">

          <input class="main" name="friend_name1*" type="text" id="friend_name1">

        </div></td>

      <td width="50%"> <div align="center">

          <input class="main" name="friend_email1*" type="text" id="friend_email1">

        </div></td>

    </tr>

    <tr>

      <td> <div align="center">

          <input class="main" name="friend_name2*" type="text" id="friend_name2">

        </div></td>

      <td> <div align="center">

          <input class="main" name="friend_email2*" type="text" id="friend_email2">

        </div></td>

    </tr>

    <tr>

      <td> <div align="center">

          <input class="main" name="friend_name3" type="text" id="friend_name3">

        </div></td>

      <td> <div align="center">

          <input class="main" name="friend_email3" type="text" id="friend_email3">

        </div></td>

    </tr>

    <tr>

      <td colspan="2"><p align="center">

          <input class="main" type="submit" name="Submit" value="Tell them">

        </p>

        <p align="center"><a href="$privacyPolicyLinkURL" target="_blank">$privacyPolicyLinkText</a><br></td>

    </tr>

  </table>

  <div align="center">

    </div>

</form>

EOD;

echo ($theForm);

}

?>

<?php

 

function spamcheck($array) {

  # returns true if data is ok, otherwise false if it is spam-looking

  return (!preg_match("/(MIME-Version:|Content-Type:|\n|\r)/i", join('',array_values($array)) ));

}

 

function myMailFunction($mailto, $subject, $message, $headers, $defaultMessageClose, $adminEmail, $notice) {

$message = $message . "\n\n" . $defaultMessageClose;

 

  // Check for suspected spam content

  if (!spamcheck(array($mailto,$subject,$headers))) {

    die('no spam please');

  }

 

if (@mail($mailto, $subject, $message, $headers)) {

  echo ('<p>Your message was successfully sent to ' . $mailto . '</p>');

if ($notice == 1) {

$message = "From email " . $headers . "\n\n" . "To email " . "\n\n" . $mailto . "\n\n" . $message;

@mail($adminEmail, "Referal notice", $message);

}

}

else {

  // This echo's the error message if the email did not send. 

  // You could change  the text in between the <p> tags.

  echo('<p>Mail could not be sent to ' . $mailto .  ' Please use your back button to try them again.</p>');

}

}

?>

<?php

function doTell ($notice, $adminEmail, $subject, $websiteName, $defaultMessageClose, $link) {

if ($_POST['your_email'] != "") {

$headers = 'From: ' . $_POST['your_name'] . '<' . $_POST['your_email'] . '>';

}

else {

$headers = 'From: ' . $websiteName . '<' . $adminEmail . '>';

}

 

 

if ($_POST['friend_email1'] != "") {

 

$mailto1 = $_POST['friend_email1'];

 

//This tacs the name onto the subject line

$subject1 = $_POST['friend_name1'] . $subject;

//This tacs the name onto the message

$message1 = $_POST['friend_name1'] . "\r\n" . $_POST['message']; 

 

 

myMailFunction($mailto1, $subject1, $message1, $headers, $defaultMessageClose, $adminEmail, $notice);

}

 

if ($_POST['friend_email2'] != "") {

 

$mailto2 = $_POST['friend_email2'];

 

//This tacs the name onto the subject line

$subject2 = $_POST['friend_name2'] . $subject;

//This tacs the name onto the message

$message2 = $_POST['friend_name2'] . "\r\n" . $_POST['message']; 

 

myMailFunction($mailto2, $subject2, $message2, $headers, $defaultMessageClose, $adminEmail, $notice);

}

if ($_POST['friend_email3'] != "") {

 

$mailto3 = $_POST['friend_email3'];

 

//This tacs the name onto the subject line

$subject3 = $_POST['friend_name3'] . $subject;

//This tacs the name onto the message

$message3 = $_POST['friend_name3'] . "\r\n" . $_POST['message']; 

 

myMailFunction($mailto3, $subject3, $message3, $headers, $defaultMessageClose, $adminEmail, $notice);

}

 

$return = <<<EOD

<p align="center"><a href="http://www.affordablemortgages.co.uk/FREE_MoneySaving_Guide.pdf">Thank you click here to now access the Free Guide.</a></p>

EOD;

 

echo ($return);

}

?>

<?php

 

if (isset($_POST['Submit'])) {

doTell($notice, $adminEmail, $subject, $websiteName, $defaultMessageClose, $link);

}

else {

doTellForm($privacyPolicyLinkText, $privacyPolicyLinkURL, $defaultMessageIntro, $link);

}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.