POST data not being 'reposted' on a second page
Posted: Mon Dec 05, 2011 4:55 pm
hello,
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)':
this takes us to the sendtofriend.php pop-up, which contains this code:
(i have edited down the code above to include just the relevant info.) as i wrote, i think the problem is that when this form (sendtofriend.php) is submitted, it does not retain and pass along the info it received from sample.htm. i have struggled with this for a few days now with no success. is there a way to keep that info in its 'memory'? i know that this could be avoided by putting the whole form in the original page (sample.htm), but the idea is that i would not have to put it in every single webpage, but rather, could have all the webpages link to one standard 'send to friend' form.
thanks for any help in advance!
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!