»»»
Send to a friend / tell a friend using php
This example shows you how to add a "tell a friend"
about this website website using php. Excellent for
making dynamic content on a website or generating income
from you revenue partners by rotating their text links.
First of all we need to create
our form for entering the friends email address ,
your name and your email address.
Here is the form example.
<form action = "tellafriend.php"
method="post">
Friends email : <input type = "text"
name ="friend"><br>
Your name : <input type = "text" name
="yourname"><br>
Your email : <input type = "text" name
="yourmail"><br>
<input type ="submit" value = "tell
friend">
</form>
As you can see this sends the
form to our script tellafriend.php , this script uses
PHP's mail () function. You can change the entries
in your own script , the second entry is what is displayed
in the emails subject (the title) and the next is
the actual message itself.
Here is the code example.
<?php
//send to a friend mail with form values
mail("$friend" , "Flashgimp Rocks"
, "Found this great site called http://www.flashgimp.com","From:
\"$yourname\" $yourmail\n");
echo ("Your email to $friend has been sent, thank
you");
?>
»»»
No output... try it on your own page!
You can drop this snippet anywhere
you like, it can be either PHP, or HTML or anything
else. You will basically have the page with a form
and a seperate page called "tellafriend.php"
When the person hits the submit button on the form,
his values are posted to the form processor "tellafriend.php"
and the info is mailed using php's mail() function.