Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 04-23-2006, 01:41 PM Tell-A-Friend Form
Novice Talker

Posts: 14
Location: Toronto, Canada
Trades: 0
Hello again..

I seem to have a lil problem with the tell-a-friend form that i just added to my website... the main problem is the fact that it's not sending the invitation to the recipients.. the 2nd problem (which is not really that big of a deal) is that it's supposed to send a copy of that invitation to my email address, and it does, but when i get that copy in my email, it's completely blank... it says:

Quote:
has used the tell-a-friend form. Their email address is

The people they have recommended are:





Here's the copy of the PHP incase anybody needs it:

Code:
<?PHP
// This following statement must be left intact.
// Taming The Beast Tell-A-Friend script V 1.2
// Taming the Beast.net - http://www.tamingthebeast.net
// Free Web Marketing and Ecommerce Resources 
// By using this code you agree to indemnify 
// Taming the Beast from from any liability that might arise 
// from it's use. 
// This following statement must be left intact. 
# This section removes any nasty tags that the user may
# have input into any of the form fields
strip_tags($friendmail1);
strip_tags($friendmail2); 
strip_tags($email); 
strip_tags($name);

# This section sends you a notification email when 
# the form is used
// Your email address (for copies to be sent to you)
$emailto = "dll_4ever@hotmail.com"; 
// Your email subject text
$esubject = "Somebody has invited you to Scandinavish.com"; 
// The email text for copies sent to you
$emailtext = "
".$name." has used the tell-a-friend form. Their email address is ".$email."
The people they have recommended are:
".$friendmail1."
".$friendmail2."
";
# Send the email to you
@mail("$emailto", $esubject, $emailtext, "From: $email");
## This section sends to the recipients
// Target page after successful submission
$thankyoupage = "thankyou.php"; 
// Change the subject text below to suit
$tsubject = "A web page recommendation from";
// Change the text below for the email 
$ttext = "
Hi,
A friend or colleague of yours, ".$name.", whose email address is ".$email." thought you may like to visit our site. ".$name." has used our Tell-a-Friend form to send you this email.
http://www.scandinavish.com/
";
# This sends the email to the addresses entered
@mail("$friendmail1,$friendmail2,$friendmail3", $tsubject, $ttext, "FROM: $email");
# After submission, the target URL
header("Location: $thankyoupage");
exit;
?>
Thanks in advance!
DLL_4ever is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-23-2006, 05:26 PM Re: Tell-A-Friend Form
Crimson's Avatar
Skilled Talker

Posts: 56
Name: Connor
Location: United States
Trades: 0
I note that you don't seem to put anything in your variables ($friendmail1, $friendmail2, $email, $name, etc.) at any point. The only variable you do actually set is also the only one that works: your email address.

You might be thinking that PHP will stick values passed to your script through GET and POST in their own individual variables automatically -- as it used to. As of PHP version 4.2.0, it doesn't, at least by default, and you have to use the superglobal arrays $_GET and $_POST.

Code:
$friendmail1 = $_GET['friendmail1'];
$friendmail2 = $_GET['friendmail2'];
$email = $_GET['email'];
$name = $_GET['name'];
 
strip_tags($friendmail1);
strip_tags($friendmail2); 
strip_tags($email); 
strip_tags($name);
 
...
You can read more about this at php.net's Using Register Globals page.

Last edited by Crimson; 04-23-2006 at 05:28 PM..
Crimson is offline
Reply With Quote
View Public Profile Visit Crimson's homepage!
 
Old 04-23-2006, 11:17 PM Re: Tell-A-Friend Form
Novice Talker

Posts: 14
Location: Toronto, Canada
Trades: 0
wow.. this is all so confusing to me.. lol

Anyways, I tried adding in the code you provided.. i still have the exact same problem.. the recipients dont recieve the invitation, and i still recieve a blank copy...

Here's a copy of the code again, incase you wanted to see it:
Code:
<?PHP
// This following statement must be left intact.
// Taming The Beast Tell-A-Friend script V 1.2
// Taming the Beast.net - http://www.tamingthebeast.net
// Free Web Marketing and Ecommerce Resources 
// By using this code you agree to indemnify 
// Taming the Beast from from any liability that might arise 
// from it's use. 
// This following statement must be left intact. 
# This section removes any nasty tags that the user may
# have input into any of the form fields
$friendmail1 = $_GET['friendmail1'];
$friendmail2 = $_GET['friendmail2'];
$email = $_GET['email'];
$name = $_GET['name'];
 
strip_tags($friendmail1);
strip_tags($friendmail2); 
strip_tags($email); 
strip_tags($name);
# This section sends you a notification email when 
# the form is used
// Your email address (for copies to be sent to you)
$emailto = "dll_4ever@hotmail.com"; 
// Your email subject text
$esubject = "Somebody has invited you to Scandinavish.com"; 
// The email text for copies sent to you
$emailtext = "
".$name." has used the tell-a-friend form. Their email address is ".$email."
The people they have recommended are:
".$friendmail1."
".$friendmail2."
";
# Send the email to you
@mail("$emailto", $esubject, $emailtext, "From: $email");
## This section sends to the recipients
// Target page after successful submission
$thankyoupage = "thankyou.php"; 
// Change the subject text below to suit
$tsubject = "A web page recommendation from";
// Change the text below for the email 
$ttext = "
Hi,
A friend or colleague of yours, ".$name.", whose email address is ".$email." thought you may like to visit our site. ".$name." has used our Tell-a-Friend form to send you this email.
http://www.scandinavish.com/
";
# This sends the email to the addresses entered
@mail("$friendmail1,$friendmail2,$friendmail3", $tsubject, $ttext, "FROM: $email");
# After submission, the target URL
header("Location: $thankyoupage");
exit;
?>
This whole field of webdesign is completely new to me, so bare with me if i misunderstood or didn't do something properly...

Thanks again in advance!

Last edited by DLL_4ever; 04-23-2006 at 11:20 PM..
DLL_4ever is offline
Reply With Quote
View Public Profile
 
Old 04-24-2006, 12:02 AM Re: Tell-A-Friend Form
Crimson's Avatar
Skilled Talker

Posts: 56
Name: Connor
Location: United States
Trades: 0
Quote:
This whole field of webdesign is completely new to me, so bare with me if i misunderstood or didn't do something properly...
Worry not, you're doing fine.
I Googled sections of your code, and it looks like the form you're using passes its information via the POST method, not GET. So try replacing all instances of $_GET in the code you just added with $_POST.

Code:
$friendmail1 = $_POST['friendmail1'];
$friendmail2 = $_POST['friendmail2'];
$email = $_POST['email'];
$name = $_POST['name'];
Also, this:

Code:
strip_tags($friendmail1);
strip_tags($friendmail2); 
strip_tags($email); 
strip_tags($name);
...should actually be:

Code:
$friendmail1 = strip_tags($friendmail1);
$friendmail2 = strip_tags($friendmail2); 
$email = strip_tags($email); 
$name = strip_tags($name);
It won't actually do anything the way you have it now.

Last edited by Crimson; 04-24-2006 at 12:10 AM..
Crimson is offline
Reply With Quote
View Public Profile Visit Crimson's homepage!
 
Old 04-24-2006, 10:05 AM Re: Tell-A-Friend Form
Novice Talker

Posts: 14
Location: Toronto, Canada
Trades: 0
Alright. So that's 1 problem fixed...

Now i get the copy of the invitation/form, with the email/name/etc... so that works.... but the recipients still don't recieve anything...

Code:
<?PHP
// This following statement must be left intact.
// Taming The Beast Tell-A-Friend script V 1.2
// Taming the Beast.net - http://www.tamingthebeast.net
// Free Web Marketing and Ecommerce Resources 
// By using this code you agree to indemnify 
// Taming the Beast from from any liability that might arise 
// from it's use. 
// This following statement must be left intact. 
# This section removes any nasty tags that the user may
# have input into any of the form fields
$friendmail1 = $_POST['friendmail1'];
$friendmail2 = $_POST['friendmail2'];
$email = $_POST['email'];
$name = $_POST['name'];
 
$friendmail1 = strip_tags($friendmail1);
$friendmail2 = strip_tags($friendmail2); 
$email = strip_tags($email); 
$name = strip_tags($name);
# This section sends you a notification email when 
# the form is used
// Your email address (for copies to be sent to you)
$emailto = "dll_4ever@hotmail.com"; 
// Your email subject text
$esubject = "Scandinavish.com Invitation Form"; 
// The email text for copies sent to you
$emailtext = "
".$name." has used the tell-a-friend form. Their email address is ".$email."
The people they have recommended are:
".$friendmail1."
".$friendmail2."
";
# Send the email to you
@mail("$emailto", $esubject, $emailtext, "From: $email");
## This section sends to the recipients
// Target page after successful submission
$thankyoupage = "thankyou.php"; 
// Change the subject text below to suit
$tsubject = "A web page recommendation from";
// Change the text below for the email 
$ttext = "
Hi,
A friend or colleague of yours, ".$name.", whose email address is ".$email." thought you may like to visit our site. ".$name." has used our Tell-a-Friend form to send you this email.
http://www.scandinavish.com/
";
# This sends the email to the addresses entered
@mail("$friendmail1,$friendmail2,$friendmail3", $tsubject, $ttext, "FROM: $email");
# After submission, the target URL
header("Location: $thankyoupage");
exit;
?>

Last edited by DLL_4ever; 04-24-2006 at 10:06 AM..
DLL_4ever is offline
Reply With Quote
View Public Profile
 
Old 04-25-2006, 08:37 PM Re: Tell-A-Friend Form
Crimson's Avatar
Skilled Talker

Posts: 56
Name: Connor
Location: United States
Trades: 0
Interesting -- when I try in on my server, it seems to send all the emails fine. Only thing I would note is that if friendmail1 and friendmail2 are the same email address, it doesn't seem to send two emails to that address, only one.

You see those @ symbols on the lines with mail(...)? Those tell PHP not to say anything if there's an error in your script.

If you remove them, at least temporarily, you might get an informative error message when you run your script, one that might point you in the right direction.

Also, you should try making the "FROM:" in your second mail() call "From:", like it is in the first call, the one that works. And I'd put a space in with the recipient addresses, just for luck:

Code:
# This sends the email to the addresses entered
mail("$friendmail1, $friendmail2, $friendmail3", $tsubject, $ttext, "From: $email");
Are you not using $friendmail3 (in other words, do you only allow users to recommend your site to a maximum of two friends)? If so, you should remove $friendmail3 from that call to mail():

Code:
# This sends the email to the addresses entered
mail("$friendmail1, $friendmail2", $tsubject, $ttext, "From: $email");
On the other hand, if you are allowing a third friend email address, you'll need to add this with the other $_POST and strip_tags() lines:

Code:
$friendmail3 = $_POST['friendmail3'];
Code:
$friendmail3 = strip_tags($friendmail3);
Crimson is offline
Reply With Quote
View Public Profile Visit Crimson's homepage!
 
Old 04-26-2006, 07:40 PM Re: Tell-A-Friend Form
Novice Talker

Posts: 14
Location: Toronto, Canada
Trades: 0
I dunno ... it seems like nomatter what I do it doesn't work... Why would it work for you and not me? Did you copy the code straight out and use it? Or did you change a couple of things in the code?

I tried to do the things you mentioned above and the problem just got worse...

I removed the @ symbols from the mail(...) thing and i got no informative error message..
I changed FROM: to From:
I added a space inbetween the recipients addresses and took away "$friendmail3" (since i only want 2 spaces/areas for email addresses...)

I saved the php, uploaded it to my webspace, tried to use it, and it wouldn't work, at all... Once i submitted the form, nothing happened. It didn't go to the Thank You page, and it didn't send anything.

Could it be my server that's for some reason causing problems? Could it be the code in the HTML that's not correctly written (i don't think it is, but I never know...)

Code:
<?PHP
// This following statement must be left intact.
// Taming The Beast Tell-A-Friend script V 1.2
// Taming the Beast.net - http://www.tamingthebeast.net
// Free Web Marketing and Ecommerce Resources 
// By using this code you agree to indemnify 
// Taming the Beast from from any liability that might arise 
// from it's use. 
// This following statement must be left intact. 
# This section removes any nasty tags that the user may
# have input into any of the form fields
$friendmail1 = $_POST['friendmail1'];
$friendmail2 = $_POST['friendmail2'];
$email = $_POST['email'];
$name = $_POST['name'];
 
$friendmail1 = strip_tags($friendmail1);
$friendmail2 = strip_tags($friendmail2); 
$email = strip_tags($email); 
$name = strip_tags($name);
# This section sends you a notification email when 
# the form is used
// Your email address (for copies to be sent to you)
$emailto = "dll_4ever@hotmail.com"; 
// Your email subject text
$esubject = "Scandinavish.com Invitation Form"; 
// The email text for copies sent to you
$emailtext = "
".$name." has used the tell-a-friend form. Their email address is ".$email."
The people they have recommended are:
".$friendmail1."
".$friendmail2."
";
# Send the email to you
mail("$emailto", $esubject, $emailtext, "From: $email");
## This section sends to the recipients
// Target page after successful submission
$thankyoupage = "thankyou.php"; 
// Change the subject text below to suit
$tsubject = "A web page recommendation from";
// Change the text below for the email 
$ttext = "
Hi,
A friend or colleague of yours, ".$name.", whose email address is ".$email." thought you may like to visit our site. ".$name." has used our Tell-a-Friend form to send you this email.
http://www.scandinavish.com/
";
# This sends the email to the addresses entered
mail("$friendmail1, $friendmail2, $tsubject, $ttext, "From: $email");
# After submission, the target URL
header("Location: $thankyoupage");
exit;
?>
DLL_4ever is offline
Reply With Quote
View Public Profile
 
Old 04-26-2006, 07:51 PM Re: Tell-A-Friend Form
Crimson's Avatar
Skilled Talker

Posts: 56
Name: Connor
Location: United States
Trades: 0
Code:
# This sends the email to the addresses entered
mail("$friendmail1, $friendmail2, $tsubject, $ttext, "From: $email");
You've removed a double quote after $friendmail2 in this line -- does putting it back in help at all?

Code:
// corrected lines:
 
# This sends the email to the addresses entered
mail("$friendmail1, $friendmail2", $tsubject, $ttext, "From: $email");
Quote:
Why would it work for you and not me? Did you copy the code straight out and use it? Or did you change a couple of things in the code?
I changed your email address to mine, but nothing else of consequence.

Last edited by Crimson; 04-26-2006 at 08:03 PM..
Crimson is offline
Reply With Quote
View Public Profile Visit Crimson's homepage!
 
Old 04-26-2006, 08:57 PM Re: Tell-A-Friend Form
Novice Talker

Posts: 14
Location: Toronto, Canada
Trades: 0
Well, it helped as in now when u send/submit the form, it goes straight to the Thank You page... I also recieve the copy of the invitation/form.. but the recipients still don't get anything!
DLL_4ever is offline
Reply With Quote
View Public Profile
 
Old 04-28-2006, 08:20 AM Re: Tell-A-Friend Form
Novice Talker

Posts: 14
Location: Toronto, Canada
Trades: 0
Anyone?
DLL_4ever is offline
Reply With Quote
View Public Profile
 
Old 04-28-2006, 09:02 AM Re: Tell-A-Friend Form
daddy2five's Avatar
Skilled Talker

Posts: 77
Name: Daniel
Location: Stony Point , Noth Carolina
Trades: 0
You know im new at this and by no means an expert or even a novice, but in your code where it says:
PHP Code:
# Send the email to you
@mail("$emailto"$esubject$emailtext"From: $email");//<---The @ symbol. 
## This section sends to the recipients
// Target page after successful submission
$thankyoupage "thankyou.php"
// Change the subject text below to suit
$tsubject "A web page recommendation from";
// Change the text below for the email 
$ttext "
Hi,
A friend or colleague of yours, "
.$name.", whose email address is ".$email." thought you may like to visit our site. ".$name." has used our Tell-a-Friend form to send you this email.
http://www.scandinavish.com/
"
;
# This sends the email to the addresses entered
@mail("$friendmail1,$friendmail2,$friendmail3"$tsubject$ttext"FROM: $email");//<---- and on this line. Why the @ symbol? 
Seems to me that the @ symbol is out of place here or dont belong. I haven't seen a mail() with the @ symbol befor. Maybe $mail() , but no @mail. Dont know if this will help, but im learning here too.
__________________
What is Yuwie?

Please login or register to view this content. Registration is FREE
daddy2five is offline
Reply With Quote
View Public Profile Visit daddy2five's homepage!
 
Old 04-28-2006, 03:55 PM Re: Tell-A-Friend Form
Novice Talker

Posts: 14
Location: Toronto, Canada
Trades: 0
/\ somebody mentioned that earlier... i tried removing the @ symbols, but still, it didn't work..
DLL_4ever is offline
Reply With Quote
View Public Profile
 
Old 04-29-2006, 04:51 PM Re: Tell-A-Friend Form
Novice Talker

Posts: 9
Trades: 0
Something unrelated to the code since that looks ok - check with your host about how to send email. I once used a host where I could not send out email using the mail() function unless the FROM email came from an email I had set up on my domain.

i.e. The domain was somedomain.net, and I was unable to send mail using the mail function UNLESS the from email was something@somedomain.net.
__________________
Webhost search -
Please login or register to view this content. Registration is FREE
striker98 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Tell-A-Friend Form
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.37122 seconds with 12 queries