Forum Moderators: coopster

Message Too Old, No Replies

Email to friend link

How do we do it?

         

DFrag

10:29 pm on Feb 12, 2004 (gmt 0)

10+ Year Member



Hello all,

How can I add one of those 'email to a friend' links one my pages? I am not sure how to go about it.

Thanks
DFrag

jatar_k

11:45 pm on Feb 12, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



When the user clicks on the link have it send the current url along to a form. The link could submit a form that has the url written into it maybe using one of the $_SERVER vars

Just have a standard mailform and pop the passed url into the email on submit.

see PHP Predefined Variables [ca2.php.net]

DFrag

12:45 am on Feb 13, 2004 (gmt 0)

10+ Year Member



This will just email then a link? I was more after the receipiant receiving an HTML email or plain text email of the story depending on what the sender chooses.

coopster

1:21 am on Feb 13, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You could take it to that level. You could open the link as a file, read it into a variable and send the html as the message content. Have a look at PHP's fopen() function and examples for an idea. And here, play around with this to get an idea of what I'm talking about (you'll have to change the link, of course!):

<?php
$fp = fopen [php.net]("http://www.mysite.com/mypage.htm", "r");
$data = fread [php.net]($fp, 1024*1024);
fclose [php.net]($fp);
header [php.net]("Content-type: text/plain");
echo [php.net] $data;
?>

jatar_k

1:24 am on Feb 13, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



ah sorry, I misunderstood.

I guess you would need a raw version of the story. If it was db driven you could grab the content of that story and then send it off.

<added>coop were just sittin waitin on this? ;) gettin slow in my old age

or what coopster said

DFrag

1:32 am on Feb 13, 2004 (gmt 0)

10+ Year Member



Cool that gives me something to go on.

Thanks guys.
DFrag

coopster

1:46 am on Feb 13, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Sure DFrag, roll with it, test some things out, give us a report on how things go!

If you get stuck...jatar_k is here to help ;)

Slow in my old age...who is he trying to kid?