PDA

View Full Version : Recommend a Friend


KevinG
08-02-2002, 01:48 PM
Hi everybody,

I am trying to build a free counter service for webmasters. My site is 75% finished - http://www.websitevrm.com (any feedback appreciated as would cool ideas for what i should i put on the home page). Anyway on the site I have made a recommend a friend form - http://www.websitevrm.com/recommend.php - but i cannot get it to work.

I don't want to use a message box, I would like to set a default message instead. My usual 'contact us' forms have a thank you page that contains the php script processor. This is the script that powers my contact forms -

<?
$sitename=getenv("HTTP_HOST");
$message.="Site: $sitename\n\n";
while ( list( $key, $val )=each($HTTP_POST_VARS) )
{
$message .="$key : $val\n" ;
}
mail("info@yoursite.com","website enquiry",$message,"From: mail.yoursite.com");
?>

The above script is great, you just place it in your thank you page and make your forms call it up. I am sure the above script can be modified to fit my email a friend form - but i cannot get it to work. any help would be greatly appreciated :)

As for websiteVRM, i have found two backend kits to power it, but i seeing as your all webmasters i am still open to suggestions. I want to try and have the site finished sometime next week.

SYP}{ER
08-02-2002, 03:23 PM
The thing is, your form is only mailing the thing to one person, you'll have to name the "X friend's name" and "X friend's email" boxes like this:

<input ... name="names[]" />
<input ... name="emails[]" />

Then in your form (you'll need a new one){

<?
$sitename=getenv("HTTP_HOST");
$message = "";
for ($i=0;$i<count($names);$i++){
$cur_name = $names[$i];
$cur_email = $emails[$i];
$message.="Site: $sitename\n\n";
$message.="Dear $cur_name,\n\n" // Fill your message in the space below.
."So and so. Visit my site please.\n\n"
."Thanks, domain.com.";
mail($cur_mail,"$senders_name would like to check this out",$message,"From: $senders_email");
$message = "";
}
?>

You get the idea, right?

PS: Naming a group of fields "name[]" will tell the server to toss their values into an array, so you can get them all with name[$i] :) Very handy.

KevinG
08-02-2002, 03:47 PM
I think i understand :thumbsup:

Will that script work for my recommend a friend form? as I can't test till I get home from work :(

btw, could you show me an example of how i should name the form elements (boxes) i.e.

your name - name form field box =
your email address - name form field box =

1st friends name - name form field box =
1st friends email - name form field box =

also on the third line of your script example is

$message = "";

what is that for as the other message variables i understand.

Ökii
08-02-2002, 04:08 PM
because Syp}{ uses $message.='add this bit'; note the dot equals part - the variable $message is stored and just added to. Therefore once it got to sending email number two it would just add the mail string onto the end of email one. You could also just lose the dot from the first definer line
$message = "Site: $sitename\n\n"; - without the dot it will just create the variable to that valuie rather than adding.

form names - depends on the info you want sent - eg if you want a mail that reads...

Dear zippy,

Bungle was recently on our site and liked it enough to have this invitation sent out to you. Visit ourspace.com

you'd need the senders name/ senders email and an array of recipient names and recipient emails

<input type="text" name="senders_name">
<input type="text" name="email">

then repeat the two lines below as many times as you like.

<input type="text" name="names[]">
<input type="text" name="emails[]">

one set of two for each poissible recipient.

then.
$message = 'Dear '.$names[$i].',

'.$senders_name[$i].' was recently on our site and liked it enough to have this invitation sent out to you. Visit '.$sitename.'.';

should work within the $i++ for loop.

KevinG
08-08-2002, 10:14 PM
Hey guys, thanks for all your help. I stuck the code in a few days ago and i still get the same errors -


Warning: Bad Message destination in D:\inetpub\websites\Casa\nThanks.php on line 27

Warning: Bad Message destination in D:\inetpub\websites\Casa\nThanks.php on line 27

Warning: Bad Message destination in D:\inetpub\websites\Casa\nThanks.php on line 27


I have spent the last few nights trying everything to get the below code working.


<?
$sitename=getenv("HTTP_HOST");
$message = "";
for ($i=0;$i<count($names);$i++){
$cur_name = $names[$i];
$cur_email = $emails[$i];
$message.="Look: $sitename\n\n";
$message.="Dear $cur_name,\n\n" // Fill your message in the space below.
."So and so. Visit my site please.\n\n"
."Thanks, www.websitevrm.com";
mail($cur_mail,"$senders_name check this out",$message,"From: $senders_email");
$message = "test test test";
}
?>


My form fields are -

senders name = field name - senders_name
senders email = field name - senders_email

friends name = field name - names[]
friends email - field name - emails[]
friends name = field name - names[]
friends email - field name - emails[]
friends name = field name - names[]
friends email - field name - emails[]

(I have 3 friend form fields, figured i should be precise and let you guys know)

I am sure its something dumb i am dong wrong.

zoobie
08-09-2002, 12:50 AM
I'm finishing a refer-a-friend in php that will make all others pale in comparison. Look for it at the end of this month @ hotscripts/php. It rocks! :thumbsup:

KevinG
08-09-2002, 08:49 AM
thanks zoob, but I would kinda like to get my site up and running now. I could be missing out on millions of dollars of revenue. maybe.

Can anyone tell me what i am doing wrong with the above script?

KevinG
08-10-2002, 03:40 PM
right this is the error i am getting - http://www.websitevrm.com/sent.php

and i am using this processor code in my thank you page

<?
$sitename=getenv("HTTP_HOST");
$message = "";
for ($i=0;$i<count($names);$i++){
$cur_name = $names[$i];
$cur_email = $emails[$i];
$message.="Look: $sitename\n\n";
$message.="Dear $cur_name,\n\n" // Fill your message in the space below.
."So and so. Visit my site please.\n\n"
."Thanks, www.websitevrm.com";
mail($cur_mail,"$senders_name check this out",$message,"From: $senders_email"); <------- line 15
$message = "";
}
?>

KevinG
08-13-2002, 09:39 AM
Ok I have got it working and it sends the email, only i still get these errors on my webpage:

Warning: Bad Message destination in D:\inetpub\websites\WebsiteVRM\sent.php on line 16

Warning: Bad Message destination in D:\inetpub\websites\WebsiteVRM\sent.php on line 16

Warning: Bad Message destination in D:\inetpub\websites\WebsiteVRM\sent.php on line 16

Warning: Bad Message destination in D:\inetpub\websites\WebsiteVRM\sent.php on line 16

This my code:

<?
$sitename=getenv("HTTP_HOST");
$message = "";
for ($i=0;$i<count($names);$i++){
$cur_name = $names[$i];
$cur_email = $emails[$i];
$message.="Look: $sitename\n\n";
$message.="Dear $cur_name,\n\n" // Fill your message in the space below.
."So and so. Visit this site please.\n\n"
."Thanks,\n\n
.$senders_name";
mail($cur_email,"Invitation from $senders_name",$message,"From: $senders_email"); - DAMN LINE 16
}
?>

I tried echoing the the mailing variables and it printed the friends name at the top of the thank you page.

MrNonchalant
08-13-2002, 08:55 PM
Your ite has a professional outlook, you ruin that with the porn joke. If anything, get rid of that.

KevinG
08-13-2002, 09:50 PM
done. thanks for the compliment.

KevinG
09-13-2002, 08:13 PM
Originally posted by zoobie
I'm finishing a refer-a-friend in php that will make all others pale in comparison. Look for it at the end of this month @ hotscripts/php. It rocks! :thumbsup:

zoob any news on that refer a friend script????

KevinG
09-19-2002, 07:49 PM
Anyone help??? puuuuuuuuuuuullllllleeeeeaaaasssssseeeeeeeee

KevinG
08-27-2005, 03:43 PM
geesus zoob,

i'm still waiting

how much longer :confused:

AaronW
08-27-2005, 04:13 PM
Just three more years. Hang in there ;)

Seriously though, your site's down now. You haven't found a refer-a-friend script yet? Or did you just dig this up for laughs?