i have tried to create a 'send to friend' form for my website using php, to which i am somewhat new. the idea is that someone can click a link on any page and a pop-up window will ask them for their info and that of their recipient and then send an e-mail with that specific webpage's title and URL. i have gotten everything to work, except for the most crucial thing -- the e-mail that sends does not include the title/URL. i believe this is because the PHP form is not passing along the info from the original webpage.
here's an example from 'Sample webpage (sample.htm)':
Code: Select all
<form method="post" action="sendtofriend.php">
<input type="hidden" name="title" value="Sample webpage">
<input type="hidden" name="url" value="sample.htm">
<input type="submit" value="Send to friend">
</form>Code: Select all
<?php
if (isset($_REQUEST['email']))
{
$title = $_REQUEST['title'] ;
$url = $_REQUEST['url'] ;
$email = $_REQUEST['email'] ;
$sender = $_REQUEST['sender'] ;
$recipient = $_REQUEST['recipient'] ;
$subject = $_REQUEST['subject'] ;
$comment = $_REQUEST['comment'] ;
$message = $sender . "wanted to send you this link: " . $title . " (" . $url . ")"
His/her comment: " . $comment ;
$from = "" . $sender . " <" . $email . ">";
$headers = "From: " . $from;
mail($recipient, $subject, stripslashes($message), $headers);
echo "Sent!";
}
else
{
echo "<form method='post' action='sendtofriend.php'>
<input type='hidden' name='subject' value='From a friend'>
Name: <input type='text' name='sender' size='40'><br>
Your e-mail: <input type='text' name='email' size='40'><br>
To: <input type='text' name='recipient' size='60'><br>
Comment: <textarea cols='60' rows='4' wrap='hard' name='comment'></textarea><br>
<input type='submit' value='Send to friend'>
</form>";
}
?>thanks for any help in advance!