Jump to content


Photo

Stuck with my tell-a-friend script


  • Please log in to reply
8 replies to this topic

#1 mehole

mehole
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 19 August 2006 - 11:19 AM

Hi

I have only very recently started learning php so I am VERY VERY new to it and have not done a lot so sorry for my lack of knowledge on the topic.

I have a php scipt that allows visitors to send a page of my site to a friend, and I was hoping to use the same script for every page but there are a couple of things I don't know how to do (well there is a lot of things I don't know how to do but this is just for this script  ;) ):
Get the URL of the current page so be displayed in the email.
I tried using:
$URI = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
But when I open the email it show the url of the actual .php file, not the url of the page that the form is on.
I have been told that I need the hard code the page to fix this but im not sure how to?

Also I am having trouble sending the e-mail to multiple email addresses, I tried using semi-colons but that didn't work, usless I put the wrong thing in. Can you use the variables separated with a semi-colon or does it have to be actual email addresses?

Thank you very much for any help anyone can give me
Mike

#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 19 August 2006 - 05:08 PM

$_SERVER['REQUEST_URI']; gets the current url, including the get method
url being
example.com/page.php?that=this
echo $_SERVER['REQUEST_URI'];
will show
/page.php?that=this
Tell me the problem, I will try tell you the solution

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 19 August 2006 - 05:39 PM

You want to know where you were before you got to the script ...

$http_referrer = $_SERVER['HTTP_REFERER']; // where did I come from??

Legend has it that reading the manual never killed anyone.
My site

#4 inqztve

inqztve
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 19 August 2006 - 05:43 PM

It's good to note HTTP_REFERER is unreliable and should not heavily rely on other than logging user behaviour etc.

#5 mehole

mehole
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 19 August 2006 - 07:14 PM

Ok I have tried using the HTTP_REFERER code but I'm now getting an error and i'm not sure what is wrong? this is my code:
<?php

$name = $_POST['name'];
$http_referrer = $_SERVER['HTTP_REFERER'];

$msg = "Hey, it's $name\n";
$msg .= "Check out this funny picture over at Mike's Joke Page\n";
$msg .= "$http_referrer\n";
$msg .= "There's also some funny videos and cool games as well\n";
$msg .= "From $name\n";

$recipient = "{$_POST['email1']};{$_POST['email2']};{$_POST['email3']};{$_POST['email4']}{$_POST['email5']};{$_POST['email6']}"; 
$subject = "Recommendation From A Friend...";

$mailheaders = "From: {$_POST[myemail]}\r\n";
$mailheaders .= "Reply-To: {$_POST[myemail]}\r\n";

mail($recipient, $subject, $msg, $mailheaders);

header("Location: http://www.mikesjokepage.com"); 
exit; 
?>

Can anyone see the problem?
Thanks
Mike

#6 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 19 August 2006 - 07:27 PM

Ok I have tried using the HTTP_REFERER code but I'm now getting an error and i'm not sure what is wrong?


Care to share what the error actually is?
Legend has it that reading the manual never killed anyone.
My site

#7 mehole

mehole
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 19 August 2006 - 08:52 PM

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, support@supportwebsite.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


It seems to only happen when I enter multiple email addresses, here is the link, can you see what happens when you try:
http://mikesjokepage...Untitled-3.html

#8 netlovers

netlovers
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 19 August 2006 - 08:58 PM

Try Apnasoft Tell a friend Script.It has every thing which u need and it is too easy to customize.click on following link.
www.apnasoft.be/scripts.html

#9 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 19 August 2006 - 09:00 PM

500's Internal error are normally something to do with config
Check your htaccess, or contact your hosting
Tell me the problem, I will try tell you the solution




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users